# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547708 | AbdelmagedNour | Igra (COCI17_igra) | C++17 | 1 ms | 340 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>
#pragma GCC optimize("Ofast")
using namespace std;
int freq1[3],freq2[3],ch[3][2]={{1,2},{0,2},{0,1}};
bool check(int c){
freq1[c]--;
bool ok=1;
if(freq1[0]+freq1[1]<freq2[2])ok=0;
if(freq1[0]+freq1[2]<freq2[1])ok=0;
if(freq1[1]+freq1[2]<freq2[0])ok=0;
if(freq2[0]+freq2[1]<freq1[2])ok=0;
if(freq2[0]+freq2[2]<freq1[1])ok=0;
if(freq2[1]+freq2[2]<freq1[0])ok=0;
freq1[c]++;
return ok;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
string s1,s2,res="";
cin>>n>>s1>>s2;
for(int i=0;i<n;i++)freq1[s1[i]-'a']++;
for(int i=0;i<n;i++)freq2[s2[i]-'a']++;
res=string(n,'a');
for(int i=0;i<n;i++){
freq2[s2[i]-'a']--;
if(check(ch[s2[i]-'a'][0]))res[i]+=ch[s2[i]-'a'][0];
else if(check(ch[s2[i]-'a'][1]))res[i]+=ch[s2[i]-'a'][1];
freq1[res[i]-'a']--;
}
cout<<res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |