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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
bool check(string s, string r) {
int n = r.size();
for (int i = 0, j = -1; i < n; ++i) {
if (j++ == n) {
return 0;
}
while (s[j] != r[i]) {
if (j++ == n) {
return 0;
}
}
}
return 1;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n; string s; cin >> n >> s;
if (n % 2 == 0) {
cout << "NOT POSSIBLE";
exit(0);
}
set<string> st;
string l = s.substr(0, n / 2), r = s.substr(n / 2, n / 2 + 1);
if (check(r, l)) {
st.insert(l);
}
l = s.substr(0, n / 2 + 1), r = s.substr(n / 2 + 1, n / 2);
if (check(l, r)) {
st.insert(r);
}
cout << (!st.size() ? "NOT POSSIBLE" : (st.size() == 1 ? *st.begin() : "NOT UNIQUE"));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |