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;
const int maxn = 2e3 + 5;
char v[maxn];
int main(){
int n; cin >> n;
for(int i = 1; i <= n; i++) cin >> v[i];
if(n%2==0) {cout << "NOT POSSIBLE\n"; return 0;}
int okcnt = 0;
string ans = "";
for(int i = 1; i <= n; i++){
bool ok = true;
for(int j = 1; j <= n/2+(i<=n/2); j++){
if(j==i) continue;
if(v[j]!=v[j+(n/2)+(i<=j+n/2)-(i<j)]) {ok = false; break;}
}
if(ok){
for(int j = 1; j <= n/2+(i<=n/2); j++){
if(j==i) continue;
ans+=v[j];
}
if(okcnt) {cout << "NOT UNIQUE\n"; return 0;}
okcnt++;
}
}
if(okcnt==0) cout << "NOT POSSIBLE\n";
else cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |