제출 #1091723

#제출 시각아이디문제언어결과실행 시간메모리
1091723raphaelp세 명의 친구들 (BOI14_friends)C++14
100 / 100
40 ms8184 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N; if (N % 2 == 0) { cout << "NOT POSSIBLE" << '\n'; return 0; } M = N / 2; string S; cin >> S; string a = S.substr(1, M), b = S.substr(M + 1, M); int tot = 0; for (int i = 0; i < M; i++) if (a[i] == b[i]) tot++; string correct(M, '0'); int match = M; if (tot == M) correct = a; for (int i = 0; i < N - 1; i++) { if (i < M) { if (a[i] == b[i]) tot--; if (a[i] == correct[i]) match--; a[i] = S[i]; if (a[i] == b[i]) tot++; if (a[i] == correct[i]) match++; } else { if (a[i - M] == b[i - M]) tot--; b[i - M] = S[i]; if (b[i - M] == a[i - M]) tot++; } if (tot == M) { if (match != M) { cout << "NOT UNIQUE" << '\n'; return 0; } if (correct[0] == '0') correct = a; } } if (correct[0] == '0') cout << "NOT POSSIBLE" << '\n'; else cout << correct; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...