Submission #796230

#TimeUsernameProblemLanguageResultExecution timeMemory
796230tch1cherinThree Friends (BOI14_friends)C++17
100 / 100
52 ms10860 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...