Submission #1041805

# Submission time Handle Problem Language Result Execution time Memory
1041805 2024-08-02T08:27:47 Z 정민찬(#11002) Bring Down the Grading Server (CEOI23_gradingserver) C++17
0 / 100
290 ms 650580 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll S, Q;
ll dp[80][80][80][80];

bool go(ll c1, ll f1, ll c2, ll f2) {
    if (c1 == 0) return false;
    if (c2 == 0) return true;
    if (f2 && c1 >= f2*S && c2 <= f1*S) return true;
    if (dp[c1][f1][c2][f2] != -1) return dp[c1][f1][c2][f2];
    if (c2 + f2*S <= c1) return true;
    if (c1 < f2*S && c2 < f1*S) {
        ll cnt1 = f2 - c1/S;
        ll cnt2 = f1 - c2/S;
        if (cnt1 <= cnt2) {
            return go(c1, f1-cnt1, c2, f2-cnt1);
        }
        else {
            return !go(c2, f2-cnt2, c1, f1-cnt2-1);
        }
    }
    if (f2) {
        if (!go(c2, f2-1, c1, f1))
            return dp[c1][f1][c2][f2] = 1;
    }
    if (f2*S < c1) {
        if (!go(c2-(c1-f2*S), f2, c1, f1))
            return dp[c1][f1][c2][f2] = 1;
    }
    return dp[c1][f1][c2][f2] = 0;
}

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    
    cin >> S >> Q;
    memset(dp, -1, sizeof(dp));
    for (ll i=0; i<Q; i++) {
        ll c1, f1, c2, f2;
        cin >> c1 >> f1 >> c2 >> f2;
        if (go(c1, f1, c2, f2)) {
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
}

Compilation message

gradingserver.cpp: In function 'bool go(ll, ll, ll, ll)':
gradingserver.cpp:27:39: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   27 |             return dp[c1][f1][c2][f2] = 1;
      |                    ~~~~~~~~~~~~~~~~~~~^~~
gradingserver.cpp:31:39: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   31 |             return dp[c1][f1][c2][f2] = 1;
      |                    ~~~~~~~~~~~~~~~~~~~^~~
gradingserver.cpp:33:31: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   33 |     return dp[c1][f1][c2][f2] = 0;
      |            ~~~~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 83 ms 321016 KB Output is correct
2 Correct 84 ms 320816 KB Output is correct
3 Runtime error 287 ms 650580 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 290 ms 650512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 320852 KB Output is correct
2 Incorrect 168 ms 321704 KB Output isn't correct
3 Halted 0 ms 0 KB -