#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 (l && i >= l*S && k <= j*S) 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:17:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
17 | return dp[i][j][k][l] = 1;
| ~~~~~~~~~~~~~~~^~~
gradingserver.cpp:21:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
21 | return dp[i][j][k][l] = 1;
| ~~~~~~~~~~~~~~~^~~
gradingserver.cpp:23:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
23 | return dp[i][j][k][l] = 0;
| ~~~~~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
118 ms |
320896 KB |
Output is correct |
2 |
Correct |
100 ms |
320824 KB |
Output is correct |
3 |
Runtime error |
334 ms |
650616 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
10 |
Correct |
106 ms |
320856 KB |
Output is correct |
11 |
Correct |
327 ms |
321724 KB |
Output is correct |
12 |
Correct |
371 ms |
321728 KB |
Output is correct |
13 |
Correct |
433 ms |
321752 KB |
Output is correct |
14 |
Correct |
615 ms |
321836 KB |
Output is correct |
15 |
Correct |
241 ms |
321704 KB |
Output is correct |
16 |
Correct |
218 ms |
321872 KB |
Output is correct |
17 |
Correct |
232 ms |
321876 KB |
Output is correct |
18 |
Correct |
422 ms |
321948 KB |
Output is correct |
19 |
Runtime error |
341 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
334 ms |
650456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
10 |
Correct |
106 ms |
320856 KB |
Output is correct |
11 |
Correct |
327 ms |
321724 KB |
Output is correct |
12 |
Correct |
371 ms |
321728 KB |
Output is correct |
13 |
Correct |
433 ms |
321752 KB |
Output is correct |
14 |
Correct |
615 ms |
321836 KB |
Output is correct |
15 |
Correct |
241 ms |
321704 KB |
Output is correct |
16 |
Correct |
218 ms |
321872 KB |
Output is correct |
17 |
Correct |
232 ms |
321876 KB |
Output is correct |
18 |
Correct |
422 ms |
321948 KB |
Output is correct |
19 |
Runtime error |
341 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
10 |
Correct |
106 ms |
320856 KB |
Output is correct |
11 |
Correct |
327 ms |
321724 KB |
Output is correct |
12 |
Correct |
371 ms |
321728 KB |
Output is correct |
13 |
Correct |
433 ms |
321752 KB |
Output is correct |
14 |
Correct |
615 ms |
321836 KB |
Output is correct |
15 |
Correct |
241 ms |
321704 KB |
Output is correct |
16 |
Correct |
218 ms |
321872 KB |
Output is correct |
17 |
Correct |
232 ms |
321876 KB |
Output is correct |
18 |
Correct |
422 ms |
321948 KB |
Output is correct |
19 |
Runtime error |
341 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
10 |
Correct |
106 ms |
320852 KB |
Output is correct |
11 |
Correct |
354 ms |
321748 KB |
Output is correct |
12 |
Correct |
386 ms |
321908 KB |
Output is correct |
13 |
Correct |
375 ms |
321872 KB |
Output is correct |
14 |
Correct |
520 ms |
321804 KB |
Output is correct |
15 |
Correct |
230 ms |
321880 KB |
Output is correct |
16 |
Correct |
199 ms |
321796 KB |
Output is correct |
17 |
Correct |
228 ms |
321876 KB |
Output is correct |
18 |
Correct |
350 ms |
321728 KB |
Output is correct |
19 |
Runtime error |
387 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
320844 KB |
Output is correct |
2 |
Correct |
371 ms |
321876 KB |
Output is correct |
3 |
Correct |
476 ms |
321920 KB |
Output is correct |
4 |
Correct |
378 ms |
321896 KB |
Output is correct |
5 |
Correct |
535 ms |
321764 KB |
Output is correct |
6 |
Correct |
231 ms |
321872 KB |
Output is correct |
7 |
Correct |
198 ms |
321872 KB |
Output is correct |
8 |
Correct |
194 ms |
321860 KB |
Output is correct |
9 |
Correct |
470 ms |
321900 KB |
Output is correct |
10 |
Correct |
106 ms |
320856 KB |
Output is correct |
11 |
Correct |
327 ms |
321724 KB |
Output is correct |
12 |
Correct |
371 ms |
321728 KB |
Output is correct |
13 |
Correct |
433 ms |
321752 KB |
Output is correct |
14 |
Correct |
615 ms |
321836 KB |
Output is correct |
15 |
Correct |
241 ms |
321704 KB |
Output is correct |
16 |
Correct |
218 ms |
321872 KB |
Output is correct |
17 |
Correct |
232 ms |
321876 KB |
Output is correct |
18 |
Correct |
422 ms |
321948 KB |
Output is correct |
19 |
Runtime error |
341 ms |
650580 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |