Submission #170596

# Submission time Handle Problem Language Result Execution time Memory
170596 2019-12-25T17:54:37 Z mdn2002 Igra (COCI17_igra) C++14
30 / 100
2 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n,c[4],d[4];
string a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("lemonade.in","r",stdin);
    //freopen("lemonade.out","w",stdout);
    cin>>n>>a>>b;
    for(int i=0; i<n; i++)c[a[i]-'a']++;
    for(int i=0; i<n; i++)d[b[i]-'a']++;
    for(int i=0; i<n; i++)
    {

        for(int j=0; j<3; j++)
        {
            d[b[i]-'a']--;
            if(b[i]-'a'==j)continue;
            if(j==0&&c[0])
            {
                if(c[1]+c[2]>=d[0]&&c[0]+c[2]-1>=d[1]&&c[0]+c[1]-1>=d[2])
                {
                    cout<<'a';
                    c[0]--;
                    break;
                }
            }
            if(j==1&&c[1])
            {
                if(c[1]+c[2]-1>=d[0]&&c[0]+c[2]>=d[1]&&c[0]+c[1]-1>=d[2])
                {
                    cout<<'b';
                    c[1]--;
                    break;
                }
            }
            if(j==2&&c[2])
            {
                if(c[1]+c[2]-1>=d[0]&&c[0]+c[2]-1>=d[1]&&c[0]+c[1]>=d[2])
                {
                    cout<<'c';
                    c[2]--;
                    break;
                }
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 276 KB Output isn't correct
9 Incorrect 2 ms 380 KB Output isn't correct
10 Incorrect 2 ms 376 KB Output isn't correct