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