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 = 2e6 + 5;
char v[maxn];
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++) cin >> v[i];
int ok = 0;
string ans = "", left="", right="";
for(int i = 0; i < n/2; i++) left+=v[i];
for(int i = n/2; i < n-1; i++) right+=v[i];
if(left==right) ok++, ans = right;
for(int i = n-2; i >= n/2; i--){
right[i-n/2] = v[i+1];
if(right==left){
ok++;
if(ok>=2 && right!=ans) {cout << "NOT UNIQUE\n"; return 0;}
ans=right;
}
}
for(int i = n/2-1; i >= 0; i--){
left[i] = v[i+1];
if(right==left){
ok++;
if(ok>=2 && left!=ans) {cout << "NOT UNIQUE\n"; return 0;}
ans=left;
}
}
if(ok==0) cout << "NOT POSSIBLE\n";
else cout << ans << '\n';
}
// #include<bits/stdc++.h>
// using namespace std;
// int main(){
// int n, k; cin >> n >> k;
// for(int i = 0; i < n; i++) cin >> v[i];
// for(int i = n-1; i >= 0; i--){
// if(v[i]=="I") cnt++;
// if(cnt>=k)
// }
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |