Submission #584325

#TimeUsernameProblemLanguageResultExecution timeMemory
584325BlagojThree Friends (BOI14_friends)C++14
35 / 100
1082 ms9376 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(0); int sz; cin >> sz; string u; cin >> u; if (sz % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } map<char, int>mp; for (int i = 0; i < sz; i++) { mp[u[i]]++; } int result = 0; string kraj, l = ""; set<string>s; for (int i = 0; i < sz; i++) { if (mp[u[i]] % 2 != 0) { string r = u.substr(i + 1); string temp = l + r; string temp1 = temp.substr(0, sz / 2), temp2 = temp.substr(sz / 2); if (temp1 == temp2 && s.count(temp1) == 0) { result++; if (result > 1) { cout << "NOT UNIQUE"; return 0; } kraj = temp1; s.insert(temp1); } } l += u[i]; } if (result == 0) { cout << "NOT POSSIBLE"; return 0; } cout << kraj; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...