Submission #1041872

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

using namespace std;
typedef long long ll;

ll S, Q;
map<array<ll,4>,bool> dp;

bool go(ll c1, ll f1, ll c2, ll f2, ll l1, ll l2) {
    if (c1 == 0) return false;
    if (c2 == 0) return true;
    if (f2 && c1 >= f2*S && c2 <= f1*S) return true;
    if (c2 + f2*S <= c1) return true;
    if (c1 >= c2 && f1 >= f2) 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, 1, 1);
        }
        else {
            return !go(c2, f2-cnt2-1, c1, f1-cnt2, 1, 1);
        }
    }
    if (f2*S < c1) {
        if (!go(c2-(c1-f2*S), f2, c1, f1, l2, l1))
            return true;
    }
    if (f2 && (c1 <= (f2+1)*S || l1 == 0)) {
        if (!go(c2, f2-1, c1, f1, l2, 1))
            return true;
    }
    return false;
}

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    
    cin >> S >> Q;
    for (ll i=0; i<Q; i++) {
        ll c1, f1, c2, f2;
        cin >> c1 >> f1 >> c2 >> f2;
        if (go(c1, f1, c2, f2, 0, 0)) {
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 504 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 455 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -