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;
int main() {
int n;
string U, A, B, T;
cin >> n >> U;
for (auto S : {U.substr(0, n / 2), U.substr((n + 1) / 2, n / 2)}) {
T = S + S;
int lcp = 0, lcs = 0;
while (lcp < n - 1 && U[lcp] == T[lcp]) ++lcp;
while (lcs < n - 1 && U[n - 1 - lcs] == T[n - 2 - lcs]) ++lcs;
if (lcp + lcs >= n - 1) A = A.empty() || A > S ? S : A, B = B.empty() || B < S ? S : B;
}
cout << (A.empty() || !(n % 2) ? "NOT POSSIBLE" : (A == B ? A : "NOT UNIQUE"));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |