답안 #1041860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041860 2024-08-02T08:49:57 Z 정민찬(#11002) Bring Down the Grading Server (CEOI23_gradingserver) C++17
0 / 100
489 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, cnt1, cnt1);
        }
        else {
            return !go(c2, f2-cnt2-1, c1, f1-cnt2, cnt2, cnt2+1);
        }
    }
    if (c1 - f2*S >= S) {
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1, l2, 0))
                return true;
        }
        if (f2 && (c1 <= f2*S || l1 <= 4)) {
            if (!go(c2, f2-1, c1, f1, l2, l1+1))
                return true;
        }
    }
    else {
        if (f2 && (c1 <= f2*S || l1 <= 4)) {
            if (!go(c2, f2-1, c1, f1, l2, l1+1))
                return true;
        }
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1, l2, 0))
                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 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 489 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 401 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 94 ms 1108 KB Output isn't correct
3 Halted 0 ms 0 KB -