# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105596 | Leonardo_Paes | Three Friends (BOI14_friends) | C++11 | 1072 ms | 6380 KiB |
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 mark[27];
int main(){
map<string, int> m;
int n;
cin >> n;
string t;
cin >> t;
for(int i=0; i<n; i++){
mark[t[i]-'A']++;
}
if(n%2==0){
cout << "NOT POSSIBLE" << endl;
return 0;
}
int x=-1;
bool resp=true;
for(int i=0; i<=26; i++){
if(mark[i]%2==1){
if(x!=-1)resp=false;
x=i;
}
}
if(resp==false){
cout << "NOT POSSIBLE" << endl;
return 0;
}
string y="-1";
string p;
int w=0;
for(int i=0; i<n; i++){
if(t[i]-'A'==x){
int u=0;
string h;
for(int j=0; j<n; j++){
if(i!=j){
h+=t[j];
u++;
}
if(u==(n-1)/2){
u=j;
break;
}
}
string q;
for(int e=u+1; e<n; e++){
if(e!=i)q+=t[e];
}
if(q==h and m.find(q)==m.end()){
if(y!="-1" and y!=q){
p="NOT UNIQUE\n";
}
y=q;
m[q]=2;
}
}
}
if(p=="NOT UNIQUE\n"){
cout << p;
}
else if(resp==false){
cout << "NOT POSSIBLE\n";
}
else{
if(y=="-1"){
cout << "NOT POSSIBLE\n";
return 0;
}
cout << y << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |