# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42599 | Hassoony | Three Friends (BOI14_friends) | C++14 | 85 ms | 6484 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>
#include<unordered_map>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=1309;
int n,fr[MX],sum;
string s;
int main(){
cin>>n>>s;
if(n%2==0){
puts("NOT POSSIBLE");
return 0;
}
for(auto pp:s)fr[pp]++;
for(int i='A';i<='Z';i++){
if(fr[i]%2)sum++;
}
if(sum!=1){
puts("NOT POSSIBLE");
return 0;
}
sum=0;
int len=(n-1)/2;
string ret="",ret1="";
bool b=0;
for(auto pp:s){
if(fr[pp]%2&&!b){b=1;continue;}
if(ret.size()!=len)ret+=pp;
else ret1+=pp;
}
if(ret!=ret1){
puts("NOT POSSIBLE");
return 0;
}
for(int i='A';i<='Z';i++){
if(fr[i]%2){
if(fr[i]!=1){
puts("NOT UNIQUE");
return 0;
}
}
}
cout<<ret<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |