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 pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef pair<ll,pairllll>pairlllll;
typedef long double ld;
typedef pair<ll,string>pairls;
#define endl '\n'
#define INF 1000000000007
#define M 1000000000
#define P 316
#define MOD 998244353
#define pb push_back
#define fr first
#define sc second
ll n,l,r,x,f;
string s,a,b;
int main()
{
cin>>n>>s;
if(n%2==0){
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
for(int i=0;i<n/2;i++){
a+=s[i];
}
for(int i=n/2+1;i<n;i++){
b+=s[i];
}
x=0;
f=0;
for(int i=n/2;i<n;i++){
if(a[x]!=s[i]){
if(f==1){
l=1;
}else{
f=1;
}
}else{
x++;
}
}
x=0;
f=0;
for(int i=0;i<=n/2;i++){
if(b[x]!=s[i]){
if(f==1){
r=1;
}else{
f=1;
}
}else{
x++;
}
}
if(l==1 && r==1)cout<<"NOT POSSIBLE"<<endl;
else if(l==0 && r==0 && a!=b)cout<<"NOT UNIQUE"<<endl;
else if(l==0)cout<<a<<endl;
else cout<<b<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |