제출 #1070469

#제출 시각아이디문제언어결과실행 시간메모리
1070469ortsac세 명의 친구들 (BOI14_friends)C++17
100 / 100
59 ms9156 KiB
#include <bits/stdc++.h> using namespace std; int32_t main() { int n; string s; cin >> n >> s; if ((n % 2) == 0) { cout << "NOT POSSIBLE\n"; return 0; } int tam = (n - 1)/2; int pos = 0; // test possibility 1 string ans1 = ""; int curr = 0; int skipped = 0; for (int i = tam; i < n; i++) { if ((curr < tam) && (s[curr] == s[i])) { curr++; } else { skipped++; } if (skipped == 2) break; } if (skipped == 1) { for (int i = 0; i < tam; i++) ans1 += s[i]; pos++; } // test possibility 2 string ans2 = ""; curr = tam + 1; skipped = 0; for (int i = 0; i <= tam; i++) { if ((curr < n) && (s[curr] == s[i])) { curr++; } else { skipped++; } if (skipped == 2) break; } if (skipped == 1) { for (int i = tam + 1; i < n; i++) ans2 += s[i]; pos++; } // gonow if (pos == 0) { cout << "NOT POSSIBLE\n"; } else if ((pos == 2) && (ans1 != ans2)) { cout << "NOT UNIQUE\n"; } else if (ans1.empty()) { cout << ans2 << "\n"; } else { cout << ans1 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...