#include <algorithm>
#include <iostream>
using namespace std;
const int N = 2000001;
char aa[N + 1];
int main() {
int n; cin >> n >> aa;
if (n % 2 == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
int m = n / 2, i_ = m;
while (i_ - m < m && aa[i_] == aa[i_ - m])
i_++;
bool yesl = true;
for (int i = i_ + 1; i < n; i++)
if (aa[i] != aa[i - m - 1]) {
yesl = false;
break;
}
i_ = m;
while (i_ + m > m && aa[i_] == aa[i_ + m])
i_--;
bool yesr = true;
for (int i = 0; i < i_; i++)
if (aa[i] != aa[i + m + 1]) {
yesr = false;
break;
}
if (!yesl && !yesr) {
cout << "NOT POSSIBLE\n";
return 0;
}
if (yesl && !yesr) {
aa[m] = '\0';
cout << aa << '\n';
return 0;
}
if (!yesl && yesr) {
cout << aa + m + 1 << '\n';
return 0;
}
for (int i = 0; i < m; i++)
if (aa[i] != aa[i + m + 1]) {
cout << "NOT UNIQUE\n";
return 0;
}
aa[m] = '\0';
cout << aa << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |