Submission #127515

#TimeUsernameProblemLanguageResultExecution timeMemory
127515TadijaSebezThree Friends (BOI14_friends)C++11
100 / 100
60 ms5240 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N=2000050; char s[N]; int main() { int n,A=0,B=0,C=0,D=0; scanf("%i",&n); scanf("%s",s+1); if(n%2==0) return 0*printf("NOT POSSIBLE\n"); int x=(n+1)/2,y=x+1,z=x-1; while(s[A+1]==s[A+x]) A++; while(s[B+1]==s[B+y]) B++; while(s[n-C]==s[x-C]) C++; while(s[n-D]==s[z-D]) D++; //printf("%i %i %i %i\n",A,B,C,D); vector<int> ans; int hal=n/2; if(B>=hal) { ans.pb(x); } else { if(B+C>=hal) ans.pb(1); if(A+D>=hal) ans.pb(n); /*for(int i=1;i<x;i++) { if(B>=i-1 && C>=x-i){ ans.pb(i);break;} } for(int i=x+1;i<=n;i++) { if(A>=i-x && D>=n-i){ ans.pb(i);break;} }*/ } if(ans.empty()) printf("NOT POSSIBLE\n"); else if(ans.size()>1) printf("NOT UNIQUE\n"); else { //printf("%i\n",ans[0]); if(ans[0]<=x) for(int i=x+1;i<=n;i++) printf("%c",s[i]); else for(int i=1;i<x;i++) printf("%c",s[i]); printf("\n"); } return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
friends.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s+1);
  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...