# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423042 | victoriad | Three Friends (BOI14_friends) | C++14 | 58 ms | 5232 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 <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
string s;
cin>>n>>s;
vector<int>can(30,0);
if(n%2==0){
cout<<"NOT POSSIBLE";
}
else{
for(int i=0;i<n;i++){
can[s[i]-65]++;
}
int l=0;
int us=-1;
vector<char> a;
int x,y;
int p=-1;
for(int i=0;i<n/2;i++){
if(s[i]==s[i+n/2]||s[i]==s[i+n/2+1]){
a.push_back(s[i]);
}
else{
if(l==0){
l=1;
p=i;
}
else{
l++;
cout<<"NOT POSSIBLE";
break;
}
}
}
if(l<=1){
if(s[n/2]!=s[0] && s[n/2]==s[n-1])a.push_back(s[n/2]);
if(a.size()!=n/2){
cout<<"NOT POSSIBLE";
}
else{
int h=-1;
for(int i=n/2;i<n;i++){
if(s[i]==s[i-n/2]||s[i]==s[i-n/2-1]){
}
else{
h=i;
}
}
if((h==-1 && p==-1)){
cout<<"NOT UNIQUE";
}
else{
for(int i=0;i<n/2;i++)cout<<a[i];
}
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |