This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*********************ALLAH HO AKBAR***********************/
/************HAZRAT MUHAMMAD (Peace be upon him)***********/
#include <bits/stdc++.h>
using namespace std;
int check1(string a,string b,int n){
bool flag=0;
for (int i = 0; i < n; ++i)
{
if(a[i]!=b[i+flag]&&flag==0)
flag=1;
if(a[i]!=b[i+flag])
return 0;
}
return 1;
}
int check2(string a,string b,int n){
bool flag=0;
for (int i = 0; i < n; ++i)
{
if(a[i+flag]!=b[i]&&flag==0)
flag=1;
if(a[i+flag]!=b[i])
return 0;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
// int n=s.length();
if(n%2==0){
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
string a="",b="",c="",d="";
for (int i = 0; i < n/2; ++i){
a+=s[i];
c+=s[i];
}
c+=s[n/2];
b+=s[n/2];
for (int i = (n/2)+1; i < n; ++i)
{
b+=s[i];
d+=s[i];
}
// cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
int k1=check1(a,b,n/2);
int k2=check2(c,d,n/2);
if(k1+k2==2&&a!=d)
cout<<"NOT UNIQUE"<<endl;
else if(k1+k2==0)
cout<<"NOT POSSIBLE"<<endl;
else if(k1==1)
cout<<a<<endl;
else
cout<<d<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |