Submission #796222

#TimeUsernameProblemLanguageResultExecution timeMemory
796222tch1cherin세 명의 친구들 (BOI14_friends)C++17
0 / 100
36 ms11112 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++;
  }
  cout << (g == 0 || !(n % 2) ? "NOT POSSIBLE" : (g == 1 ? A : "NOT UNIQUE"));
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...