제출 #1231713

#제출 시각아이디문제언어결과실행 시간메모리
1231713Tenis0206Bring Down the Grading Server (CEOI23_gradingserver)C++20
5 / 100
646 ms73476 KiB
#include <bits/stdc++.h>

using namespace std;

const int nmax = 75;

bool dp[nmax + 5][nmax + 5][nmax + 5][nmax + 5];
bool sel[nmax + 5][nmax + 5][nmax + 5][nmax + 5];

int s, q;

bool solve(int C, int F, int c, int f)
{
    if(C <= 0)
    {
        return false;
    }
    if(sel[C][F][c][f])
    {
        return dp[C][F][c][f];
    }
    sel[C][F][c][f] = true;
    dp[C][F][c][f] = false;
    if(C - f * s > 0 && !solve(c - (C - f * s), f, C, F))
    {
        dp[C][F][c][f] = true;
    }
    else if(f > 0 && !solve(c, f - 1, C, F))
    {
        dp[C][F][c][f] = true;
    }
    return dp[C][F][c][f];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifdef home
    freopen("nr.in","r",stdin);
    freopen("nr.out","w",stdout);
#endif // home
    cin>>s>>q;
    for(int i=1; i<=q; i++)
    {
        int ch, fh, cg, fg;
        cin>>ch>>fh>>cg>>fg;
        bool ok = solve(ch, fh, cg, fg);
        if(ok)
        {
            cout<<"YES\n";
        }
        else
        {
            cout<<"NO\n";
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...