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;
typedef long long ll;
typedef long double ld;
const int maxn = 2e6 + 10;
int f[maxn];
int main(){
ios_base::sync_with_stdio(false);
int n;
string s;
cin >> n >> s;
set<string> allstr;
if (!(n & 1))
return cout << "NOT POSSIBLE\n", 0;
int len = n / 2;
int now = len + 1;
for (int i = 0; i <= len; i++)
if (now < n and s[i] == s[now])
now ++;
if (now >= n)
allstr.insert(s.substr(len + 1, len));
now = 0;
for (int i = len; i < n; i++)
if (now < len and s[i] == s[now])
now ++;
if (now >= len)
allstr.insert(s.substr(0, len));
if (allstr.size() == 0)
return cout << "NOT POSSIBLE\n", 0;
if (allstr.size() > 1)
return cout << "NOT UNIQUE\n", 0;
cout << *allstr.begin() << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |