This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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),r=s.substr(n/2,n/2+1);
for(int i=0;i<n/2;i++) {
if(l[i]!=r[i+f]) f=1;
res1+=l[i];
res2+=r[i+f];
}
ans1=(res1 == res2 ? res1 : "");
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(r[i]!=l[i+f]) f=1;
res1+=r[i];
res2+=l[i+f];
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |