Submission #554510

#TimeUsernameProblemLanguageResultExecution timeMemory
554510ollelThree Friends (BOI14_friends)C++14
100 / 100
106 ms8196 KiB
using namespace std; #include <bits/stdc++.h> #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef long long ll; int n,m; string u; int main() { cin >> n; cin >> u; n = u.size(); if (n % 2 == 0) { cout << "NOT POSSIBLE\n"; exit(0); } m = (n - 1) / 2; bool first = true, second = true; int i = 0, j = m; while (i < m) { if (u[i] != u[j]) break; i++; j++; } j++; while (i < m) { if (u[i] != u[j]) break; i++; j++; } first = (i == m); i = 0; j = m + 1; while (j < n) { if (u[i] != u[j]) break; i++; j++; } i++; while (j < n) { if (u[i] != u[j]) break; i++; j++; } second = (j == n); vector<char> s, f; rep(i,0,m) f.pb(u[i]); rep(i,m+1,n) s.pb(u[i]); bool eq = true; rep(i,0,m) if (f[i] != s[i]) eq = false; if ((!eq) && first && second) { cout << "NOT UNIQUE\n"; } else if (first) { rep(i,0,m) cout << f[i]; cout << endl; } else if (second) { rep(i,0,m) cout << s[i]; cout << endl; } else { cout << "NOT POSSIBLE\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...