Submission #203457

#TimeUsernameProblemLanguageResultExecution timeMemory
203457mdn2002Three Friends (BOI14_friends)C++14
100 / 100
127 ms12308 KiB
#include<bits/stdc++.h> using namespace std; int n; string a,x,ox,y,oy; int main() { cin>>n>>a; if(n%2==0) { cout<<"NOT POSSIBLE"; return 0; } for(int i=0;i<n/2;i++)x.push_back(a[i]); for(int i=(n/2)+1;i<n;i++)y.push_back(a[i]); ox=x; oy=y; x+=x; y+=y; int cnt=0,aa=0,bb=0; for(int i=0,j=0;i<n;i++) { if(a[i]==x[j])j++; else cnt++; if(cnt>1)break; if(i==n-1)aa++; } cnt=0; for(int i=0,j=0;i<n;i++) { if(a[i]==y[j])j++; else cnt++; if(cnt>1)break; if(i==n-1)bb++; } if(aa+bb==0) { cout<<"NOT POSSIBLE"; return 0; } if(aa+bb==2&&ox!=oy) { cout<<"NOT UNIQUE"; return 0; } if(aa)cout<<ox; else if(bb)cout<<oy; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...