Submission #1093114

#TimeUsernameProblemLanguageResultExecution timeMemory
1093114juicyThree Friends (BOI14_friends)C++17
100 / 100
10 ms10260 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif bool check(string s, string r) { int n = r.size(); for (int i = 0, j = -1; i < n; ++i) { if (j++ == n) { return 0; } while (s[j] != r[i]) { if (j++ == n) { return 0; } } } return 1; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; string s; cin >> n >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE"; exit(0); } set<string> st; string l = s.substr(0, n / 2), r = s.substr(n / 2, n / 2 + 1); if (check(r, l)) { st.insert(l); } l = s.substr(0, n / 2 + 1), r = s.substr(n / 2 + 1, n / 2); if (check(l, r)) { st.insert(r); } cout << (!st.size() ? "NOT POSSIBLE" : (st.size() == 1 ? *st.begin() : "NOT UNIQUE")); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...