Submission #398739

#TimeUsernameProblemLanguageResultExecution timeMemory
398739faresbasbsThree Friends (BOI14_friends)C++14
35 / 100
1088 ms6280 KiB
#include <bits/stdc++.h> using namespace std; string s; int n; int main(){ cin >> n >> s; if(n%2 == 0){ cout << "NOT POSSIBLE" << endl; return 0; } vector<string> ans; for(int i = 0 ; i < n ; i += 1){ string s1="",s2=""; int pos = 0 , cnt = 0; while(cnt < n/2){ if(pos == i){ pos += 1; continue; } s1 += s[pos]; pos += 1 , cnt += 1; } while(pos < n){ if(pos == i){ pos += 1; continue; } s2 += s[pos]; pos += 1 , cnt += 1; } if(s1 == s2){ ans.push_back(s1); } } sort(ans.begin(),ans.end()); ans.erase(unique(ans.begin(),ans.end()),ans.end()); if(ans.size() == 0){ cout << "NOT POSSIBLE" << endl; }else if(ans.size() == 1){ cout << ans[0] << endl; }else{ cout << "NOT UNIQUE" << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...