This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
string s;
cin >> n >> s;
if (n % 2 == 0) {
cout << "NOT POSSIBLE";
return 0;
}
string a = s.substr(0, n / 2);
string b = s.substr(n / 2 + 1);
int i = 0;
for (int j = n / 2; j < n; j++) {
if (i < n / 2 && s[j] == a[i]) {
i++;
}
}
int cnt = 0;
int first = 0;
if (i == n / 2) {
cnt++;
first = 1;
}
i = 0;
for (int j = 0; j <= n / 2; j++) {
if (i < n / 2 && s[j] == b[i]) {
i++;
}
}
if (i == n / 2) {
cnt++;
}
if (!cnt) {
cout << "NOT POSSIBLE";
}
if (cnt == 1) {
if (first) {
cout << a;
} else {
cout << b;
}
}
if (cnt == 2) {
if (a == b) {
cout << a;
} else {
cout << "NOT UNIQUE";
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |