# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
656202 | 600Mihnea | 세 명의 친구들 (BOI14_friends) | C++17 | 1088 ms | 13048 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 = 0;
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;
}
string s;
cin >> s;
assert((int) s.size() == n);
int half = (n - 1) / 2;
string pref(s.begin(), s.begin() + half);
string suf(s.end() - half, s.end());
int cnt = 0;
string goods;
vector<string> trs;
if (pref == suf) {
trs = {pref + pref};
} else {
trs = {pref + pref, suf + suf};
}
for (auto &tr : trs) {
assert((int) tr.size() == n - 1);
bool ok = 0;
for (int skip = 0; skip < n; skip++) {
string lol = string(s.begin(), s.begin() + skip) + string(s.begin() + skip + 1, s.end());
assert((int) lol.size() == n - 1);
ok |= (lol == tr);
}
if (ok) {
cnt++;
goods = tr;
}
}
if (cnt == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
if (cnt == 2) {
cout << "NOT UNIQUE\n";
return 0;
}
assert(cnt == 1);
goods.resize(half);
cout << goods << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |