Submission #370391

# Submission time Handle Problem Language Result Execution time Memory
370391 2021-02-24T01:16:14 Z TosakaUCW Igra (COCI17_igra) C++17
20 / 100
1 ms 364 KB
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>

int n, cnt1[3], cnt2[3];
std::string s, t, ans;

bool check(int i, int j)
{
    cnt1[j]--, cnt2[t[i] - 'a']--;
    for (int i = 0; i < 3; i++)
    {
        int sum = 0;
        for (int j = 0; j < 3; j++)
            if (i ^ j)
                sum += cnt2[j];
        if (cnt1[i] > sum)
            return cnt1[j]++, cnt2[t[i] - 'a']++, false;
    }
    return true;
}

int main()
{
    std::cin >> n >> s >> t;
    for (int i = 0; i < n; i++)
        cnt1[s[i] - 'a']++, cnt2[t[i] - 'a']++;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            if (cnt1[j] and j != t[i] - 'a' and check(i, j))
            {
                ans += j + 'a';
                break;
            }
    return std::cout << ans, 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Incorrect 1 ms 364 KB Output isn't correct