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
#define all(x) x.begin(), x.end()
int N, pt, a;
char U[2000010];
bool front, back, uni;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
if (N%2 == 0){
cout << "NOT POSSIBLE";
return 0;
}
cin >> U;
pt = (N-1)/2;
a = 0;
front = true;
while (a < (N-1)/2){
if (pt > N-1){
front = false;
break;
}
if (U[pt] != U[a]){
pt++;
continue;
}
else {
pt++;
a++;
}
}
pt = 0;
a = (N+1)/2;
back = true;
while (a < N){
if (pt > (N-1)/2){
back = false;
break;
}
if (U[pt] != U[a]){
pt++;
continue;
}
else{
pt++;
a++;
}
}
if (back and front){
for (int i = 0; i < (N-1)/2; i++){
if (U[i] != U[i+(N+1)/2]){
cout << "NOT UNIQUE";
return 0;
}
}
for (int i = 0; i < (N-1)/2; i++){
cout << U[i];
}
}
else if (!back and !front){
cout << "NOT POSSIBLE";
}
else if (front){
for (int i = 0; i < (N-1)/2; i++){
cout << U[i];
}
}
else{
for (int i = (N+1)/2; i < N; i++){
cout << U[i];
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |