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;
int N;
char c;
char ok[2000010];
int pt;
bool ans1, ans2;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
if(!N%2){
cout << "NOT POSSIBLE";
return 0;
}
int k = N/2;
for(int a=1; a<=N; a++){
cin >> ok[a];
}
ans1 = ans2 = true;
pt = k+1;
for(int a=1; a<=k; a++){
while(pt != N+1 && ok[pt] != ok[a]) {
pt++;
}
if(pt == N+1){
ans1 = false;
break;
}
pt++;
}
pt = 1;
for(int a=k+2; a<=N; a++){
while(pt != k+2 && ok[pt] != ok[a]) {
pt++;
}
if(pt == k+2){
ans2 = false;
break;
}
pt++;
}
if(ans1 && ans2){
for(int a=1; a<=k; a++){
if(ok[a] != ok[a+k+1]){
cout << "NOT UNIQUE";
return 0;
}
}
for(int a=1; a<=k; a++){
cout << ok[a];
}
}
else if(ans1){
for(int a=1; a<=k; a++){
cout << ok[a];
}
}
else if(ans2){
for(int a=k+2; a<=N; a++){
cout << ok[a];
}
}
else{
cout << "NOT POSSIBLE";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |