This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef long long ll;
int n,m;
string u;
int main() {
cin >> n; m = (n - 1) / 2;
cin >> u;
bool first = true, second = true;
int j = m - 1;
rep(i,0,m) {
j++;
if (u[i] == u[j]) continue;
j++;
if (j > i + m + 1) {first = false; break;}
}
j = -1;
rep(i,m+1,n) {
j++;
if (u[i] == u[j]) continue;
j++;
if (j > i - m) {second = false; break;}
}
vector<char> s, f;
rep(i,0,m) f.pb(u[i]);
rep(i,m+1,n) s.pb(u[i]);
bool eq = true;
rep(i,0,m) if (f[i] != s[i]) eq = false;
if ((!eq) && first && second) {
cout << "NOT UNIQUE\n";
} else if (first) {
rep(i,0,m) cout << f[i];
cout << endl;
} else if (second) {
rep(i,0,m) cout << s[i];
cout << endl;
} else {
cout << "NOT POSSIBLE\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |