Submission #727440

#TimeUsernameProblemLanguageResultExecution timeMemory
727440AdamGSThree Friends (BOI14_friends)C++17
100 / 100
39 ms9524 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() bool check(string s, string u) { int l=0, ile=0; for(auto i : s) { if(i==u[l]) { ++l; ile+=l/u.size(); l%=u.size(); } } return ile>=2; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; string s; cin >> n >> s; if(n%2==0) { cout << "NOT POSSIBLE\n"; return 0; } string a="", b=""; rep(i, n/2) { a+=s[i]; b+=s[(n+1)/2+i]; } bool ok1=check(s, a), ok2=check(s, b); if(ok1 && ok2 && a!=b) { cout << "NOT UNIQUE\n"; return 0; } if(!ok1 && !ok2) { cout << "NOT POSSIBLE\n"; return 0; } cout << (ok1?a:b) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...