Submission #1041845

# Submission time Handle Problem Language Result Execution time Memory
1041845 2024-08-02T08:41:22 Z 정민찬(#11002) Bring Down the Grading Server (CEOI23_gradingserver) C++17
10 / 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) {
    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);
        }
        else {
            return !go(c2, f2-cnt2-1, c1, f1-cnt2);
        }
    }
    if (c1 - f2*S >= S) {
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1))
                return true;
        }
        if (f2) {
            if (!go(c2, f2-1, c1, f1))
                return true;
        }
    }
    else {
        if (f2) {
            if (!go(c2, f2-1, c1, f1))
                return true;
        }
        if (f2*S < c1) {
            if (!go(c2-(c1-f2*S), f2, c1, f1))
                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)) {
            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 446 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 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 157 ms 1104 KB Output is correct
12 Correct 123 ms 1104 KB Output is correct
13 Correct 50 ms 1124 KB Output is correct
14 Correct 46 ms 1164 KB Output is correct
15 Correct 63 ms 1236 KB Output is correct
16 Correct 61 ms 1308 KB Output is correct
17 Correct 76 ms 1136 KB Output is correct
18 Correct 49 ms 1164 KB Output is correct
19 Correct 2283 ms 1348 KB Output is correct
20 Correct 834 ms 1104 KB Output is correct
21 Correct 120 ms 1116 KB Output is correct
22 Correct 66 ms 1148 KB Output is correct
23 Correct 100 ms 1284 KB Output is correct
24 Correct 100 ms 1220 KB Output is correct
25 Correct 103 ms 1352 KB Output is correct
26 Correct 117 ms 1360 KB Output is correct
27 Correct 103 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 485 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 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 157 ms 1104 KB Output is correct
12 Correct 123 ms 1104 KB Output is correct
13 Correct 50 ms 1124 KB Output is correct
14 Correct 46 ms 1164 KB Output is correct
15 Correct 63 ms 1236 KB Output is correct
16 Correct 61 ms 1308 KB Output is correct
17 Correct 76 ms 1136 KB Output is correct
18 Correct 49 ms 1164 KB Output is correct
19 Correct 2283 ms 1348 KB Output is correct
20 Correct 834 ms 1104 KB Output is correct
21 Correct 120 ms 1116 KB Output is correct
22 Correct 66 ms 1148 KB Output is correct
23 Correct 100 ms 1284 KB Output is correct
24 Correct 100 ms 1220 KB Output is correct
25 Correct 103 ms 1352 KB Output is correct
26 Correct 117 ms 1360 KB Output is correct
27 Correct 103 ms 1144 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 178 ms 1256 KB Output is correct
30 Correct 114 ms 1208 KB Output is correct
31 Correct 82 ms 1104 KB Output is correct
32 Correct 50 ms 1264 KB Output is correct
33 Correct 92 ms 1240 KB Output is correct
34 Correct 88 ms 1108 KB Output is correct
35 Correct 93 ms 1284 KB Output is correct
36 Correct 75 ms 1188 KB Output is correct
37 Correct 2242 ms 1140 KB Output is correct
38 Correct 766 ms 1164 KB Output is correct
39 Correct 157 ms 1108 KB Output is correct
40 Correct 65 ms 1104 KB Output is correct
41 Correct 81 ms 1108 KB Output is correct
42 Correct 61 ms 1148 KB Output is correct
43 Correct 105 ms 1296 KB Output is correct
44 Correct 82 ms 1360 KB Output is correct
45 Correct 70 ms 1360 KB Output is correct
46 Correct 236 ms 1836 KB Output is correct
47 Execution timed out 4074 ms 636 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 157 ms 1104 KB Output is correct
12 Correct 123 ms 1104 KB Output is correct
13 Correct 50 ms 1124 KB Output is correct
14 Correct 46 ms 1164 KB Output is correct
15 Correct 63 ms 1236 KB Output is correct
16 Correct 61 ms 1308 KB Output is correct
17 Correct 76 ms 1136 KB Output is correct
18 Correct 49 ms 1164 KB Output is correct
19 Correct 2283 ms 1348 KB Output is correct
20 Correct 834 ms 1104 KB Output is correct
21 Correct 120 ms 1116 KB Output is correct
22 Correct 66 ms 1148 KB Output is correct
23 Correct 100 ms 1284 KB Output is correct
24 Correct 100 ms 1220 KB Output is correct
25 Correct 103 ms 1352 KB Output is correct
26 Correct 117 ms 1360 KB Output is correct
27 Correct 103 ms 1144 KB Output is correct
28 Runtime error 485 ms 1048576 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 147 ms 1256 KB Output is correct
12 Correct 76 ms 1108 KB Output is correct
13 Correct 44 ms 1108 KB Output is correct
14 Correct 47 ms 1104 KB Output is correct
15 Correct 51 ms 1304 KB Output is correct
16 Correct 53 ms 1292 KB Output is correct
17 Correct 60 ms 1108 KB Output is correct
18 Correct 41 ms 1104 KB Output is correct
19 Execution timed out 4042 ms 520 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 143 ms 1220 KB Output is correct
3 Correct 111 ms 1108 KB Output is correct
4 Correct 49 ms 1136 KB Output is correct
5 Correct 46 ms 1220 KB Output is correct
6 Correct 53 ms 1104 KB Output is correct
7 Correct 87 ms 1108 KB Output is correct
8 Correct 66 ms 1104 KB Output is correct
9 Correct 42 ms 1216 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 157 ms 1104 KB Output is correct
12 Correct 123 ms 1104 KB Output is correct
13 Correct 50 ms 1124 KB Output is correct
14 Correct 46 ms 1164 KB Output is correct
15 Correct 63 ms 1236 KB Output is correct
16 Correct 61 ms 1308 KB Output is correct
17 Correct 76 ms 1136 KB Output is correct
18 Correct 49 ms 1164 KB Output is correct
19 Correct 2283 ms 1348 KB Output is correct
20 Correct 834 ms 1104 KB Output is correct
21 Correct 120 ms 1116 KB Output is correct
22 Correct 66 ms 1148 KB Output is correct
23 Correct 100 ms 1284 KB Output is correct
24 Correct 100 ms 1220 KB Output is correct
25 Correct 103 ms 1352 KB Output is correct
26 Correct 117 ms 1360 KB Output is correct
27 Correct 103 ms 1144 KB Output is correct
28 Runtime error 485 ms 1048576 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -