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;
#define int long long int
const int mod = 1e9+7;
#undef int
int main()
{
#define int long long int
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
if(!(n&1))
{
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
int c = n/2, skip = 0;
bool poss = true;string ans1 = "", ans2 = "";
for(int i = 0;i<n/2;i++, c++)
{
if(s[i]!=s[c])
{
if(skip)
{
poss = false;
break;
}
skip++;
i--;
}
}
if(poss)
ans1 = s.substr(0, n/2);
poss = true;
c = 0, skip = 0;
for(int i = n/2+1;i<n;i++, c++)
{
if(s[i]!=s[c])
{
if(skip)
{
poss = false;
break;
}
skip++;
i--;
}
}
if(poss)
ans2 = s.substr(n/2+1);
if(ans1!=""&&ans2!=""&&ans1!=ans2)
cout<<"NOT UNIQUE"<<endl;
else if(ans1!="")
cout<<ans1<<endl;
else if(ans2!="")
cout<<ans2<<endl;
else
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |