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>
#define pb push_back
#define ff first
#define ss second
#define M 2000001
typedef long long ll;
const int p=53;
const int MOD=1000000007;
using namespace std;
char s[M];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for(int i=0;i<n;++i) cin >> s[i];
if((n&1)==0){
cout << "NOT POSSIBLE";
return 0;
}
bool t=0;
for(int i=1;i<n/2;i++){
if(s[i]!=s[i+n/2]){
t=1;
break;
}
}
if(t==0 && s[0]==s[n/2] && s[0]==s[n-1] && s[0]!=s[1]){
cout << "NOT UNIQUE";
return 0;
}
string a="",x="";
bool flag=0,f=0;
int zuruu=n/2;
for(int i=0;i<n/2;i++){
if(s[i]!=s[i+zuruu]){
if(flag==1){
f=1;
break;
}
flag=1;
zuruu++;
if(s[i]!=s[i+zuruu]){
f=1;
break;
}
}
x=x+s[i];
}
if(f==0){
cout << x;
return 0;
}
flag=0,f=0,zuruu=n/2+1;
for(int i=0;i<=(n/2);i++){
if(s[i]!=s[i+zuruu]){
if(flag==1){
f=1;
break;
}
zuruu=n/2;
flag=1;
i++;
if(s[i]!=s[i+zuruu]){
f=1;
break;
}
}
if(i>(n/2)) break;
a=a+s[i];
}
if(f==0){
cout << a;
return 0;
}
cout << "NOT POSSIBLE";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |