Submission #398888

#TimeUsernameProblemLanguageResultExecution timeMemory
398888almosabhaliThree Friends (BOI14_friends)C++14
0 / 100
44 ms13924 KiB
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fast(); int n; string s; cin>>n>>s; // for(char c:s) counter[c-'A']++; // int odd=0; // char index; // for(int i=0;i<26;i++) { // odd+=(counter[i]%2); // if(counter[i]%2) index=i+'A'; // } // if(odd!=1) cout<<"NOT POSSIBLE\n"; if(n%2==0) { cout<<"NOT POSSIBLE\n"; return 0; } // cout<<"debug\n"; string ans1,ans2; bool f=0; string res1,res2; string l,r; f=0; res1.clear(); res2.clear(); l=s.substr(0,n/2+1),r=s.substr(n/2+1,n/2); for(int i=0;i<n/2;i++) { if(l[i+f]!=r[i]) f=1; res1+=l[i+f]; res2+=r[i]; } ans1=(res1 == res2 ? res1 : ""); f=0; res1.clear(); res2.clear(); l=s.substr(0,n/2),r=s.substr(n/2,n/2+1); for(int i=0;i<n/2;i++) { if(r[i+f]!=l[i]) f=1; res1+=r[i+f]; res2+=l[i]; } ans2=(res1 == res2 ? res1 : ""); if(ans1.size() && ans2.size() && ans1!=ans2) cout<<"NOT UNIQUE\n"; else if(!ans1.size() && !ans2.size()) cout<<"NOT POSSIBLE\n"; else cout<<ans1+ans2<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...