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 int long long
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
char a[n];
for(int i=0;i<n;i++)cin>>a[i];
if(n%2==0){
cout<<"NOT POSSIBLE";
return 0;
}
int in=n/2,c=0,co=2,s=1,check=0;
for(int i=0;i<n/2;i++){
if(a[i]==a[i+in+c]);
else{
if(i==0)check=1;
i--;
if(c==1){
co--;
break;
}c++;
}
}
in++;c=0;
for(int i=0;i<n/2;i++){
if(a[i+c]==a[i+in]);
else{
i--;
if(c==1){
s=0;
co--;
break;
}c++;
}
}
if(co==2&&check==0)cout<<"NOT UNIQUE";
else if(co==0)cout<<"NOT POSSIBLE";
else{
if(s){
c=0;
for(int i=0;i<n/2;i++){
if(a[i+c]==a[i+n/2+1])cout<<a[i+c];
else {i--;c++;}
}
}else{
c=0;
for(int i=0;i<n/2;i++){
if(a[i]==a[i+n/2+c])cout<<a[i];
else {i--;c++;}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |