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(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);s
int n;
cin >> n;
string s;
cin >> s;
int l = (n-1)/2;
if((n%2) == 0){
cout << "NOT POSSIBLE";
return 0;
}
string ans1="",ans2="";
for(int i=0;i<l;i++){
ans1+=s[i];
}
for(int i=l+1;i<n;i++){
ans2+=s[i];
}
bool ok1=0,ok2=0;
int cnt = 0;
for(int i=l;i<n && cnt<l;i++){
if(ans1[cnt] == s[i]){
cnt++;
}
}
ok1 = (cnt == l);
cnt = 0;
for(int i=0;i<=l && cnt<l;i++){
if(ans2[cnt] == s[i]){
cnt++;
}
}
ok2 = (cnt ==l);
if(!ok1 && !ok2){
cout << "NOT POSSIBLE";
return 0;
}
if(ok1 && ok2 && (ans1 != ans2)){
cout << "NOT UNIQUE";
return 0;
}
if(ok1){
cout << ans1;
return 0;
}
cout << ans2;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |