제출 #554507

#제출 시각아이디문제언어결과실행 시간메모리
554507ollel세 명의 친구들 (BOI14_friends)C++14
0 / 100
88 ms6284 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 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...