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<iostream>
#include<string>
using namespace std;
const int mod=1e9+7;
int len;
string s,a,b;
int f(int st,bool use)
{
if(st==b.size())
{
if(!use) return 1;
else return a[st]==b[st-1];
}
int res=use?0:f(st+1,true);
if(a[st]!=b[st-use]) return res;
else return f(st+1,use)+res;
}
long long pow[2000002];
long long prefix[2000002];
int main()
{
cin>>len>>s;
if(!(len&1) || len==1) { cout<<"NOT POSSIBLE"; return 0; }
a=s.substr(0,len/2+1);
b=s.substr(len/2+1,len/2);
int cnt1=f(0,false);
a=s.substr(len/2,len/2+1);
b=s.substr(0,len/2);
int cnt2=f(0,false);
if(cnt1+cnt2==0) cout<<"NOT POSSIBLE";
else if(cnt1+cnt2>=2) cout<<"NOT UNIQUE";
else cout<<(cnt1?s.substr(len/2+1,len/2):s.substr(0,len/2));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |