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;
string s;
int n;
int main(){
cin >> n >> s;
if(n%2 == 0){
cout << "NOT POSSIBLE" << endl;
return 0;
}
vector<string> ans;
for(int i = 0 ; i < n ; i += 1){
string s1="",s2="";
int pos = 0 , cnt = 0;
while(cnt < n/2){
if(pos == i){
pos += 1;
continue;
}
s1 += s[pos];
pos += 1 , cnt += 1;
}
while(pos < n){
if(pos == i){
pos += 1;
continue;
}
s2 += s[pos];
pos += 1 , cnt += 1;
}
if(s1 == s2){
ans.push_back(s1);
}
}
if(ans.size() == 0){
cout << "NOT POSSIBLE" << endl;
}else if(ans.size() == 1){
cout << ans[0] << endl;
}else{
cout << "NOT UNIQUE" << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |