# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
728776 | rominanafu | Three Friends (BOI14_friends) | C++11 | 1074 ms | 6116 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;
int n, len;
string s;
string r1, r2;
bool unico = true;
bool posible(int x) {
int ini = 0, fin = len;
if (x < fin)
fin++;
int cont=0;
while (cont < len) {
if (ini == x)
ini++;
if (fin == x)
fin++;
if (fin == n) {
break;
}
if (s[ini] != s[fin])
return false;
ini++;
fin++;
cont++;
}
return true;
}
int main() {
ios_base::sync_with_stdio();
cin.tie();
cin >> n >> s;
len = n/2;
for(int i=0; i<n; i++) {
if (posible(i)) {
r2 = r1;
if (i <= len)
r1 = s.substr(len+1, len);
else
r1 = s.substr(0, len);
if (r2.size() == len && r1 != r2) {
unico = false;
break;
}
}
}
if (r1.length() != len || (n&1) == 0)
cout << "NOT POSSIBLE\n";
else if (!unico)
cout << "NOT UNIQUE\n";
else
cout << r1 << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |