# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
656211 | 600Mihnea | Three Friends (BOI14_friends) | C++17 | 13 ms | 13060 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;
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) {
int pcom = 0, scom = 0;
while (pcom < n - 1 && tr[pcom] == s[pcom]) {
pcom++;
}
while (scom < n - 1 && tr[(int) tr.size() - 1 - scom] == s[(int) s.size() - 1 - scom]) {
scom++;
}
if (pcom >= n - 1 - scom) {
cnt++;
goods = tr;
}
}
if (cnt == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
if (cnt == 2) {
cout << "NOT UNIQUE\n";
return 0;
}
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... |