Submission #547708

# Submission time Handle Problem Language Result Execution time Memory
547708 2022-04-11T14:05:17 Z AbdelmagedNour Igra (COCI17_igra) C++17
30 / 100
1 ms 340 KB
#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
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 1 ms 316 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 320 KB Output isn't correct
8 Incorrect 0 ms 320 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct