# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
656196 | 600Mihnea | 세 명의 친구들 (BOI14_friends) | C++17 | 0 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
bool home = 1;
bool verbose = 1;
#include <bits/stdc++.h>
using namespace std;
int main() {
if (!home) {
verbose = 0;
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
if (home) {
verbose = 1;
freopen ("___input___.txt", "r", stdin);
}
int n;
cin >> n;
if (n % 2 == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
assert((n - 1) % 2 == 0);
int half = (n - 1) / 2;
string s;
cin >> s;
assert((int) s.size() == n);
int cnt = 0, pskip;
for (int i = 0; i < n; i++) {
string t = string(s.begin(), s.begin() + i) + string(s.begin() + i + 1, s.end());
assert((int) t.size() == n - 1);
assert((int) t.size() == 2 * half);
bool ok = 1;
for (int j = 0; j < half; j++) {
ok &= (t[j] == t[j + half]);
}
if (ok) {
cnt++;
pskip = i;
}
}
if (cnt == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
if (cnt >= 2) {
cout << "NOT UNIQUE\n";
return 0;
}
string t = string(s.begin(), s.begin() + pskip) + string(s.begin() + pskip + 1, s.end());
t.resize((int) t.size() / 2);
cout << t << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |