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>
#define ll long long
using namespace std;
ll n,i;
string ans="",u,s,t;
bool check(string s,string t){
ll n=s.size(),i,j=0;
bool a=1;
for(i=0;i<n;i++){
if(s[i]==t[j]){
j++;
continue;
}
else if(a){
j++;
a=0;
if(s[i]!=t[j]) return 0;
else j++;
}
else return 0;
}
return 1;
}
int main(){
cin >> n >> u;
if(n%2==0){
cout << "NOT POSSIBLE";
return 0;
}
s=u.substr(0,n/2);
t=u.substr(n/2,n);
if(check(s,t)) ans=s;
s=u.substr(n/2+1,n);
t=u.substr(0,n/2+1);
if(check(s,t)){
if(ans=="" || ans==s) cout << s;
else cout << "NOT UNIQUE";
}
else if(ans=="") cout << "NOT POSSIBLE";
else cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |