제출 #796240

#제출 시각아이디문제언어결과실행 시간메모리
796240tch1cherin세 명의 친구들 (BOI14_friends)C++17
100 / 100
54 ms11980 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...