Submission #316023

#TimeUsernameProblemLanguageResultExecution timeMemory
316023sofapudenThree Friends (BOI14_friends)C++14
100 / 100
103 ms8336 KiB
#include <bits/stdc++.h> using namespace std; vector<string> ans; void tr(string a, string b){ int cn[3]; cn[0] = cn[1] = cn[2] = 0; while(cn[0] < (int)a.size() && cn[1] < (int)b.size()){ if(a[cn[0]] == b[cn[1]]){cn[0]++, cn[1]++;} else{cn[2]++; cn[1]++;} } if(cn[2] > 1)return; if(ans.empty()){ans.push_back(a);return;} if(ans[0] != a){ans.push_back(a);return;} } int main(){ int n; cin >> n; string s; cin >> s; if(!(n&1)){cout << "NOT POSSIBLE\n";return 0;} n/=2; tr(s.substr(0,n),s.substr(n,n+1)); tr(s.substr(n+1,n), s.substr(0,n+1)); if(ans.empty()){cout << "NOT POSSIBLE\n";return 0;} if(ans.size() == 1){cout << ans[0] << "\n"; return 0;} cout << "NOT UNIQUE\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...