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 pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=2e3;
int n;
string s;
bool sa(int x){
int l, p;
if(x<n/2+1)
l=1, p=n/2+2;
else
l=1, p=n/2+1;
if(l==x) l++;
if(p==x) p++;
for(int i=1; i<=n/2; i++){
if(s[l]!=s[p])
return false;
l++, p++;
if(l==x) l++;
if(p==x) p++;
}
return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>n>>s;
if(n%2==0){
cout<<"NOT POSSIBLE\n";
return 0;
}
s='%'+s
; int ile=0, wyn;
for(int i=1;i<=n; i++){
if(sa(i))
ile++, wyn=i;
}
if(!ile)
cout<<"NOT POSSIBLE\n";
else if(ile>1)
cout<<"NOT UNIQUE\n";
else{
int xd=0;
for(int i=1; i<=n; i++){
if(i!=wyn){
cout<<s[i];
xd++;
}
if(xd==n/2)
break;
}
cout<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |