답안 #1041858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041858 2024-08-02T08:48:12 Z 정민찬(#11002) Bring Down the Grading Server (CEOI23_gradingserver) C++17
0 / 100
445 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, bool l1, bool 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, true, true);
        }
        else {
            return !go(c2, f2-cnt2-1, c1, f1-cnt2, true, true);
        }
    }
    if (c1 - f2*S >= S) {
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1, l2, false))
                return true;
        }
        if (f2 && (c1 <= f2*S || !l1)) {
            if (!go(c2, f2-1, c1, f1, l2, true))
                return true;
        }
    }
    else {
        if (f2 && (c1 <= f2*S || !l1)) {
            if (!go(c2, f2-1, c1, f1, l2, true))
                return true;
        }
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1, l2, false))
                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, false, false)) {
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 429 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 445 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 204 ms 1128 KB Output isn't correct
3 Halted 0 ms 0 KB -