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;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
bool check(string s, string u) {
int l=0, ile=0;
for(auto i : s) {
if(i==u[l]) {
++l;
ile+=l/u.size();
l%=u.size();
}
}
return ile>=2;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
string s;
cin >> n >> s;
if(n%2==0) {
cout << "NOT POSSIBLE\n";
return 0;
}
string a="", b="";
rep(i, n/2) {
a+=s[i];
b+=s[(n+1)/2+i];
}
bool ok1=check(s, a), ok2=check(s, b);
if(ok1 && ok2 && a!=b) {
cout << "NOT UNIQUE\n";
return 0;
}
if(!ok1 && !ok2) {
cout << "NOT POSSIBLE\n";
return 0;
}
cout << (ok1?a:b) << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |