제출 #931292

#제출 시각아이디문제언어결과실행 시간메모리
931292Bulbasheen세 명의 친구들 (BOI14_friends)C++14
100 / 100
25 ms5284 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() int N, pt, a; char U[2000010]; bool front, back, uni; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> N; if (N%2 == 0){ cout << "NOT POSSIBLE"; return 0; } cin >> U; pt = (N-1)/2; a = 0; front = true; while (a < (N-1)/2){ if (pt > N-1){ front = false; break; } if (U[pt] != U[a]){ pt++; continue; } else { pt++; a++; } } pt = 0; a = (N+1)/2; back = true; while (a < N){ if (pt > (N-1)/2){ back = false; break; } if (U[pt] != U[a]){ pt++; continue; } else{ pt++; a++; } } if (back and front){ for (int i = 0; i < (N-1)/2; i++){ if (U[i] != U[i+(N+1)/2]){ cout << "NOT UNIQUE"; return 0; } } for (int i = 0; i < (N-1)/2; i++){ cout << U[i]; } } else if (!back and !front){ cout << "NOT POSSIBLE"; } else if (front){ for (int i = 0; i < (N-1)/2; i++){ cout << U[i]; } } else{ for (int i = (N+1)/2; i < N; i++){ cout << U[i]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...