Submission #100746

#TimeUsernameProblemLanguageResultExecution timeMemory
100746dalgerokIgra (COCI17_igra)C++17
0 / 100
3 ms384 KiB
#include<bits/stdc++.h>
using namespace std;


int cnt1[3], cnt2[3];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n; i++){
        cnt1[s[i] - 'a'] += 1;
        cnt2[t[i] - 'a'] += 1;
    }
    for(int i = 0; i < n; i++){
        cnt2[t[i] - 'a'] -= 1;
        for(int j = 0; j < 3; j++){
            if(t[i] - 'a' != j){
                if(j == 0 && cnt1[0]){
                    if(cnt1[0] - 1 + cnt1[1] >= cnt2[2] && cnt1[0] - 1 + cnt1[2] >= cnt2[1]){
                        cout << 'a';
                        cnt1[0] -= 1;
                        break;
                    }
                }
                if(j == 1 && cnt1[1]){
                    if(cnt1[1] - 1 + cnt1[2] >= cnt2[0] && cnt1[1] - 1 + cnt1[0] >= cnt2[2]){
                        cout << 'b';
                        cnt1[1] -= 1;
                        break;
                    }
                }
                if(j == 2 & cnt1[2]){
                    if(cnt1[2] - 1 + cnt1[1] >= cnt2[0] && cnt1[2] - 1 + cnt1[0] >= cnt2[1]){
                        cout << 'c';
                        cnt1[2] -= 1;
                        break;
                    }
                }
            }
        }
    }
}

Compilation message (stderr)

igra.cpp: In function 'int main()':
igra.cpp:35:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
                 if(j == 2 & cnt1[2]){
                    ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...