# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84689 | teomrn | Three Friends (BOI14_friends) | C++14 | 85 ms | 25308 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.
#include <bits/stdc++.h>
using namespace std;
string ans;
bool uniq;
void proc(string a, string b)
{
if (a.size() < b.size())
swap(a, b);
char c = 0;
int p = 0;
for (auto i : a) {
if (p == b.size() || b[p] != i) {
if (c)
return;
c = i;
p--;
}
p++;
}
if (c) {
if (!ans.empty() && ans != b)
uniq = 1;
ans = b;
}
}
int main()
{
int l;
cin >> l;
string s;
cin >> s;
if (l % 2 == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
proc(s.substr(0, l / 2), s.substr(l / 2, l / 2 + 1));
proc(s.substr(0, l / 2 + 1), s.substr(l / 2 + 1, l / 2));
if (uniq)
cout << "NOT UNIQUE\n";
else if (ans.empty())
cout << "NOT POSSIBLE\n";
else
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |