Submission #392771

#TimeUsernameProblemLanguageResultExecution timeMemory
392771AlmaThree Friends (BOI14_friends)C++14
0 / 100
1077 ms6276 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; string S; cin >> S; if (N % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } int extraChar = 0, numSubstr = 0; char left = ' ', right = ' '; for (int i = 1; i <= N/2; i++) left ^= S[i]; for (int i = N/2 + 1; i < N; i++) right ^= S[i]; if (left == right) { string a = "", b = ""; for (int i = 0; i < N; i++) { if (i == extraChar) continue; if ((int)a.size() < N/2) { a += S[i]; } else { b += S[i]; } } if (a == b) numSubstr++; } for (int currChar = 1; currChar <= N/2; currChar++) { left ^= S[currChar]; left ^= S[currChar - 1]; if (left == right) { extraChar = currChar; string a = "", b = ""; for (int i = 0; i < N; i++) { if (i == extraChar) continue; if ((int)a.size() < N/2) { a += S[i]; } else { b += S[i]; } } if (a == b) numSubstr++; } } for (int currChar = N/2 + 1; currChar < N; currChar++) { right ^= S[currChar]; right ^= S[currChar - 1]; if (left == right) { extraChar = currChar; string a = "", b = ""; for (int i = 0; i < N; i++) { if (i == extraChar) continue; if ((int)a.size() < N/2) { a += S[i]; } else { b += S[i]; } } if (a == b) numSubstr++; } } if (numSubstr == 0) { cout << "NOT POSSIBLE\n"; } else if (numSubstr > 1) { cout << "NOT UNIQUE\n"; } else { string a = "", b = ""; for (int i = 0; i < N; i++) { if (i == extraChar) continue; if ((int)a.size() < N/2) { a += S[i]; } else { b += S[i]; } } if (a == b) cout << a << '\n'; else cout << "NOT POSSIBLE\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...