Submission #554503

#TimeUsernameProblemLanguageResultExecution timeMemory
554503ollelThree Friends (BOI14_friends)C++14
0 / 100
97 ms6244 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; m = (n - 1) / 2; cin >> u; bool first = true, second = true; int j = m - 1; rep(i,0,m) { j++; if (u[i] == u[j]) continue; j++; if (j > i + m + 1) {first = false; break;} if (u[i] != u[j]) {first = false; break;} } j = -1; rep(i,m+1,n) { j++; if (u[i] == u[j]) continue; j++; if (j > i - m) {second = false; break;} if (u[i] != u[j]) {second = false; break;} } 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...