Submission #135728

#TimeUsernameProblemLanguageResultExecution timeMemory
135728forelaxThree Friends (BOI14_friends)C++14
100 / 100
128 ms7284 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int m;cin>>m; if(m%2==0){ cout<<"NOT POSSIBLE"; return 0; } int n=m/2; string a; cin>>a; string fa=a.substr(0,n); string fb=a.substr(n); string sa=a.substr(0,n+1); string sb=a.substr(n+1); // cout<<fa<<" "<<fb<<endl<<sa<<" "<<sb<<endl; int vff,vfb; int vsf,vsb; for( vff=0 ; vff < n ; vff ++) if(fa[vff]!=fb[vff])break; for( vfb=0 ; vfb < n ; vfb ++) if(fa[n-1-vfb]!=fb[n-vfb])break; for( vsf=0 ; vsf < n ; vsf ++) if(sa[vsf]!=sb[vsf])break; for( vsb=0 ; vsb < n ; vsb ++) if(sa[n-vsb]!=sb[n-1-vsb])break; // cout<<vff<<" "<<vfb<<endl<<vsf<<" "<<vsb<<endl; int sf=vff+vfb; int ss=vsf+vsb; if(sf<n&&ss<n){ cout<<"NOT POSSIBLE"; return 0; } if(sf>=n&&ss>=n){ if(fa==sb) cout<<fa; else cout<<"NOT UNIQUE"; return 0; } if(sf>=n) cout<<fa; else if(ss>=n) cout<<sb; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...