Submission #520692

#TimeUsernameProblemLanguageResultExecution timeMemory
520692sidonThree Friends (BOI14_friends)C++17
100 / 100
13 ms6168 KiB
#include <bits/stdc++.h> using namespace std; string s; int n; bool match(int i, int j, int p = 0) { for(int k = 0; k <= n; k++) p += p < n && s[i+p] == s[j+k]; return p == n; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> s; if(!(n & 1)) return !(cout << "NOT POSSIBLE"); n /= 2; bool L = match(0, n), R = match(n+1, 0); if(!L && !R) return !(cout << "NOT POSSIBLE"); if(L && R && s.substr(0, n) != s.substr(n+1, n)) cout << "NOT UNIQUE"; else cout << s.substr(R*(n+1), n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...