This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of God
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
if(n % 2 == 0) {
cout << "NOT POSSIBLE";
exit(0);
}
int ans = 0;
for(int i = 0; i < n; i++) {
string tmp = "";
if(i == 0) tmp = s.substr(i+1, n-1);
else tmp = s.substr(0, i) + s.substr(i+1, n - i - 1);
if(tmp.substr(0, tmp.length()/2) == tmp.substr(tmp.length()/2, tmp.length()/2)) ans++;
}
if(ans == 0) cout << "NOT POSSIBLE";
if(ans > 1) cout << "NOT UNIQUE";
if(ans == 1) {
for(int i = 0; i < n; i++) {
string tmp = "";
if(i == 0) tmp = s.substr(i+1, n-1);
else tmp = s.substr(0, i) + s.substr(i+1, n - i - 1);
if(tmp.substr(0, tmp.length()/2) == tmp.substr(tmp.length()/2, tmp.length()/2)) {
cout << tmp.substr(0, tmp.length() / 2);
exit(0);
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |