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 i = 0, j = m;
while (i < m) {
if (u[i] != u[j]) break;
i++; j++;
}
j++;
while (i < m) {
if (u[i] != u[j]) break;
i++; j++;
}
first = (i == m);
i = 0; j = m + 1;
while (j < n) {
if (u[i] != u[j]) break;
i++; j++;
}
i++;
while (j < n) {
if (u[i] != u[j]) break;
i++; j++;
}
second = (j == n);
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... |