# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42967 | BThero | Three Friends (BOI14_friends) | C++14 | 12 ms | 4672 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>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
char ans[2000005];
char s[2000005];
char t[2000005];
int n, sz;
void solve() {
scanf("%d", &n);
scanf("%s", s);
if (n % 2 == 0) {
printf("NOT POSSIBLE\n");
return;
}
assert(n <= 5000);
int len = (n - 1) / 2;
bool did = 0;
for (int i = 0; i < n; ++i) {
sz = 0;
for (int j = 0; j < n; ++j) {
if (j != i) {
t[sz++] = s[j];
}
}
bool ok = 1;
for (int j = 0; j < len; ++j) {
if (t[j] != t[j + len]) {
ok = 0;
}
}
if (ok) {
if (did) {
for (int j = 0; j < len; ++j) {
if (t[j] != ans[j]) {
printf("NOT UNIQUE\n");
return;
}
}
}
did = 1;
for (int j = 0; j < len; ++j) {
ans[j] = t[j];
}
}
}
if (!did) {
printf("NOT POSSIBLE\n");
return;
}
for (int i = 0; i < len; ++i) {
printf("%c", ans[i]);
}
}
int main() {
#ifdef BThero
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // BThero
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |