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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
string str;
int main(){
cin>>n>>str;
string one, two;
int i, t;
if(n%2 == 0){
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
for(i = 0; i < n/2; i++)
if(str[i] != str[i+n/2]) break;
t = i;
for(i = n/2-1; i>= 0; i--)
if(str[i] != str[i+n/2+1]) break;
int flag;
if(t > i) flag = 1;
else flag = 0;
for(i = 0; i < n/2+1; i++)
if(str[i] != str[i+n/2+1]) break;
t = i;
for(i = n/2; i >= 0; i--)
if(str[i] != str[i+n/2]) break;
if(t >= i){
if(flag){
for(i = 0; i < n/2; i++)
if(str[i] != str[i+n/2+1]) break;
if(i == n/2){
string out;
for(i = 0; i < n/2; i++) out.pb(str[i]);
cout<<out<<endl;
}
else
cout<<"NOT UNIQUE"<<endl;
}
else{
string out;
for(i = 0; i <n/2; i++) out.pb(str[i+n/2+1]);
cout<<out<<endl;
}
}
else{
if(flag){
string out;
for(i = 0; i < n/2; i++) out.pb(str[i]);
cout<<out<<endl;
}
else
cout<<"NOT POSSIBLE"<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |