Submission #397086

#TimeUsernameProblemLanguageResultExecution timeMemory
397086AlmaThree Friends (BOI14_friends)C++17
0 / 100
13 ms7208 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; } bool left = true, l = true; string leftPart = s.substr(0, n/2); int a = 0, b = n/2; while (a < n/2 && b < n) { if (leftPart[a] != s[b]) { if (l) { b++; l = false; } else { left = false; break; } } a++; b++; } bool right = true, r = true; string rightPart = s.substr(n/2+1, n/2); int c = 0, d = 0; while (c < n/2 && d <= n/2) { if (rightPart[c] != s[d]) { if (r) { d++; r = false; } else { right = false; break; } } 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...