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;
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int n,m,b[200005],a[200005],k,flag,t,mpp[50],one,cev;
char c;
string s,ss,yaz,s1,s2;
vector<int> v;
int main(void){
fio();
cin>>n>>s;
if(n%2==0){cout<<"NOT POSSIBLE\n";return 0;}
for(int i=0;i<n;i++){
mpp[s[i]-'A']++;
}
for(int i=0;i<=25;i++){
if(mpp[i]%2){
cev++;
c=i+'A';
}
}
for(int i=0;i<n/2;i++)s1+=s[i];
for(int i=n/2+1;i<n;i++)s2+=s[i];
if(cev!=1){cout<<"NOT POSSIBLE\n";return 0;}
int bas=0;
int son=n/2;
cev=0;
while(son<n){
if(s[bas]!=s[son] && s[son]==c && flag==0){
son++;
flag=1;
}
else if(s[bas]!=s[son]){flag=2;break;}
else{bas++;son++;}
}
if(flag!=2){
cev++;
one=1;
}
flag=0;
bas=n/2;
son=n-1;
if(s1!=s2){
while(bas>=0){
//~ cout<<s[bas]<<" ;; "<<s[son]<<endl;
if(s[bas]!=s[son] && s[bas]==c && flag==0){
bas--;
flag=1;
}
else if(s[bas]!=s[son]){flag=2;break;}
else{bas--;son--;}
}
if(flag!=2)cev++;
}
if(cev==2){cout<<"NOT UNIQUE\n";return 0;}
if(cev==0){cout<<"NOT POSSIBLE\n";return 0;}
if(one==1){
cout<<s1<<endl;
return 0;
}
cout<<s2<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |