# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42596 | Hassoony | Three Friends (BOI14_friends) | C++14 | 79 ms | 6668 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=309;
int n,fr[MX],sum;
string s;
int main(){
cin>>n>>s;
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;
for(int i='A';i<='Z';i++){
if(fr[i]%2){
if(fr[i]!=1){
puts("NOT UNIQUE");
return 0;
}
}
}
int len=(n-1)/2;
string ret="";
for(auto pp:s){
if(fr[pp]%2||ret.size()==len)continue;
ret+=pp;
}
cout<<ret<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |