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;
int main()
{
int n;
string s;
cin>>n>>s;
if(n%2==0) {cout<<"NOT POSSIBLE"; return 0;}
int p=n/2;
bool sm=true;
for(int i=0;i<p;i++) if(s[i]!=s[p+1+i]) sm=false;
int tp=0,td=0;
for(int i=0;i<p && tp<=1;i++) while(s[i]!=s[i+p+tp] && tp<=1) tp++;
for(int i=n-1;i>=n-p && td<=1;i--) while(s[i]!=s[i-p-td] && td<=1) td++;
if(sm) {for(int i=0;i<p;i++) cout<<s[i]; return 0;}
if(tp>1 && td>1) {cout<<"NOT POSSIBLE"; return 0;}
if(tp<=1 && td<=1) {cout<<"NOT UNIQUE"; return 0;}
if(td>1) {for(int i=0;i<p;i++) cout<<s[i]; return 0;}
for(int i=p+1;i<n;i++) cout<<s[i];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |