#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll S, Q;
ll dp[80][80][80][80];
bool go(ll i, ll j, ll k, ll l) {
if (i == 0) return false;
if (k == 0) return true;
if (dp[i][j][k][l] != -1) return dp[i][j][k][l];
if (k + l*S <= i) return true;
if (l) {
if (!go(k, l-1, i, j))
return dp[i][j][k][l] = 1;
}
if (l*S < i) {
if (!go(k-(i-l*S), l, i, j))
return dp[i][j][k][l] = 1;
}
return dp[i][j][k][l] = 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:16:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
16 | return dp[i][j][k][l] = 1;
| ~~~~~~~~~~~~~~~^~~
gradingserver.cpp:20:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
20 | return dp[i][j][k][l] = 1;
| ~~~~~~~~~~~~~~~^~~
gradingserver.cpp:22:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
22 | return dp[i][j][k][l] = 0;
| ~~~~~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
320968 KB |
Output is correct |
2 |
Runtime error |
334 ms |
650660 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
10 |
Correct |
111 ms |
320852 KB |
Output is correct |
11 |
Correct |
425 ms |
321880 KB |
Output is correct |
12 |
Correct |
489 ms |
321872 KB |
Output is correct |
13 |
Correct |
400 ms |
321832 KB |
Output is correct |
14 |
Correct |
505 ms |
321916 KB |
Output is correct |
15 |
Correct |
207 ms |
321872 KB |
Output is correct |
16 |
Correct |
226 ms |
321868 KB |
Output is correct |
17 |
Correct |
240 ms |
321872 KB |
Output is correct |
18 |
Correct |
394 ms |
321748 KB |
Output is correct |
19 |
Runtime error |
343 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
383 ms |
650580 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
10 |
Correct |
111 ms |
320852 KB |
Output is correct |
11 |
Correct |
425 ms |
321880 KB |
Output is correct |
12 |
Correct |
489 ms |
321872 KB |
Output is correct |
13 |
Correct |
400 ms |
321832 KB |
Output is correct |
14 |
Correct |
505 ms |
321916 KB |
Output is correct |
15 |
Correct |
207 ms |
321872 KB |
Output is correct |
16 |
Correct |
226 ms |
321868 KB |
Output is correct |
17 |
Correct |
240 ms |
321872 KB |
Output is correct |
18 |
Correct |
394 ms |
321748 KB |
Output is correct |
19 |
Runtime error |
343 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
10 |
Correct |
111 ms |
320852 KB |
Output is correct |
11 |
Correct |
425 ms |
321880 KB |
Output is correct |
12 |
Correct |
489 ms |
321872 KB |
Output is correct |
13 |
Correct |
400 ms |
321832 KB |
Output is correct |
14 |
Correct |
505 ms |
321916 KB |
Output is correct |
15 |
Correct |
207 ms |
321872 KB |
Output is correct |
16 |
Correct |
226 ms |
321868 KB |
Output is correct |
17 |
Correct |
240 ms |
321872 KB |
Output is correct |
18 |
Correct |
394 ms |
321748 KB |
Output is correct |
19 |
Runtime error |
343 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
10 |
Correct |
95 ms |
320908 KB |
Output is correct |
11 |
Correct |
418 ms |
321872 KB |
Output is correct |
12 |
Correct |
403 ms |
321936 KB |
Output is correct |
13 |
Correct |
359 ms |
321884 KB |
Output is correct |
14 |
Correct |
481 ms |
321800 KB |
Output is correct |
15 |
Correct |
226 ms |
321896 KB |
Output is correct |
16 |
Correct |
229 ms |
321876 KB |
Output is correct |
17 |
Correct |
238 ms |
321876 KB |
Output is correct |
18 |
Correct |
479 ms |
321812 KB |
Output is correct |
19 |
Runtime error |
336 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
320856 KB |
Output is correct |
2 |
Correct |
372 ms |
321904 KB |
Output is correct |
3 |
Correct |
404 ms |
321900 KB |
Output is correct |
4 |
Correct |
391 ms |
321916 KB |
Output is correct |
5 |
Correct |
518 ms |
321784 KB |
Output is correct |
6 |
Correct |
217 ms |
321876 KB |
Output is correct |
7 |
Correct |
249 ms |
321728 KB |
Output is correct |
8 |
Correct |
218 ms |
321868 KB |
Output is correct |
9 |
Correct |
459 ms |
321916 KB |
Output is correct |
10 |
Correct |
111 ms |
320852 KB |
Output is correct |
11 |
Correct |
425 ms |
321880 KB |
Output is correct |
12 |
Correct |
489 ms |
321872 KB |
Output is correct |
13 |
Correct |
400 ms |
321832 KB |
Output is correct |
14 |
Correct |
505 ms |
321916 KB |
Output is correct |
15 |
Correct |
207 ms |
321872 KB |
Output is correct |
16 |
Correct |
226 ms |
321868 KB |
Output is correct |
17 |
Correct |
240 ms |
321872 KB |
Output is correct |
18 |
Correct |
394 ms |
321748 KB |
Output is correct |
19 |
Runtime error |
343 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |