# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42964 | BThero | Three Friends (BOI14_friends) | C++14 | 11 ms | 4796 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 <assert.h>
#include <stdio.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
char s[2000005];
int n, ans;
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;
ans = -1;
for (int i = 0; i < n; ++i) {
int l = 0, r = len;
if (i == 0) {
++l;
}
if (i <= r) {
++r;
}
bool ok = 1;
while (r < n) {
if (s[l] != s[r]) {
ok = 0;
}
if (++l == i) {
++l;
}
if (++r == i) {
++r;
}
}
if (ok) {
if (ans != -1) {
printf("NOT UNIQUE\n");
return;
}
ans = i;
}
}
if (ans == -1) {
printf("NOT POSSIBLE\n");
return;
}
for (int i = 0, cnt = 0; cnt < len; ++i) {
if (i == ans) {
continue;
}
printf("%c", s[i]);
++cnt;
}
}
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... |