Submission #396707

#TimeUsernameProblemLanguageResultExecution timeMemory
396707AlmaThree Friends (BOI14_friends)C++14
0 / 100
23 ms7480 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } // left: bool left = true, l = true; int a = 0, b = n/2; string leftPart = ""; while (a < n/2 && b < n) { if (s[a] != s[b]) { if (l) { b++; l = false; } else { left = false; } } leftPart += s[a]; a++; b++; } // right: bool right = true, r = true; int c = n/2+1, d = 0; string rightPart = ""; while (c < n && d <= n/2) { if (s[c] != s[d]) { if (r) { d++; r = false; } else { right = false; } } rightPart += s[c]; c++; d++; } if (left && right) { if (leftPart == rightPart) cout << leftPart << '\n'; else cout << "NOT UNIQUE\n"; } else if (left) { cout << leftPart << '\n'; } else if (right) { cout << rightPart << '\n'; } else { cout << "NOT POSSIBLE\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...