#include <bits/stdc++.h>
using namespace std;
const int Nmax=80, INF=1e9;
int S, Q, D[Nmax][Nmax][Nmax][Nmax];
bool visited[Nmax][Nmax][Nmax][Nmax];
bool F(int a, int b, int c, int d) {
if(a<=0) return false;
if(visited[a][b][c][d]) return D[a][b][c][d];
visited[a][b][c][d]=true;
if((d>=1 && !F(c, d-1, a, b)) || !F(c-max(0, a-d*S), d, a, b)) D[a][b][c][d]=true;
return D[a][b][c][d];
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>S>>Q;
while(Q--) {
int ch, fh, cg, fg;
cin>>ch>>fh>>cg>>fg;
if(F(ch, fh, cg, fg)) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
2 ms |
348 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
509 ms |
184004 KB |
Output is correct |
12 |
Correct |
469 ms |
185152 KB |
Output is correct |
13 |
Correct |
506 ms |
186504 KB |
Output is correct |
14 |
Correct |
513 ms |
186776 KB |
Output is correct |
15 |
Correct |
447 ms |
185288 KB |
Output is correct |
16 |
Correct |
460 ms |
185712 KB |
Output is correct |
17 |
Correct |
448 ms |
185500 KB |
Output is correct |
18 |
Correct |
512 ms |
184624 KB |
Output is correct |
19 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
509 ms |
184004 KB |
Output is correct |
12 |
Correct |
469 ms |
185152 KB |
Output is correct |
13 |
Correct |
506 ms |
186504 KB |
Output is correct |
14 |
Correct |
513 ms |
186776 KB |
Output is correct |
15 |
Correct |
447 ms |
185288 KB |
Output is correct |
16 |
Correct |
460 ms |
185712 KB |
Output is correct |
17 |
Correct |
448 ms |
185500 KB |
Output is correct |
18 |
Correct |
512 ms |
184624 KB |
Output is correct |
19 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
509 ms |
184004 KB |
Output is correct |
12 |
Correct |
469 ms |
185152 KB |
Output is correct |
13 |
Correct |
506 ms |
186504 KB |
Output is correct |
14 |
Correct |
513 ms |
186776 KB |
Output is correct |
15 |
Correct |
447 ms |
185288 KB |
Output is correct |
16 |
Correct |
460 ms |
185712 KB |
Output is correct |
17 |
Correct |
448 ms |
185500 KB |
Output is correct |
18 |
Correct |
512 ms |
184624 KB |
Output is correct |
19 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
476 ms |
180804 KB |
Output is correct |
12 |
Correct |
471 ms |
182352 KB |
Output is correct |
13 |
Correct |
475 ms |
183668 KB |
Output is correct |
14 |
Correct |
482 ms |
183888 KB |
Output is correct |
15 |
Correct |
468 ms |
182608 KB |
Output is correct |
16 |
Correct |
465 ms |
182864 KB |
Output is correct |
17 |
Correct |
442 ms |
182612 KB |
Output is correct |
18 |
Correct |
516 ms |
181396 KB |
Output is correct |
19 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
488 ms |
183632 KB |
Output is correct |
3 |
Correct |
473 ms |
184976 KB |
Output is correct |
4 |
Correct |
490 ms |
186192 KB |
Output is correct |
5 |
Correct |
507 ms |
186704 KB |
Output is correct |
6 |
Correct |
446 ms |
185172 KB |
Output is correct |
7 |
Correct |
466 ms |
185680 KB |
Output is correct |
8 |
Correct |
439 ms |
185532 KB |
Output is correct |
9 |
Correct |
525 ms |
184148 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
509 ms |
184004 KB |
Output is correct |
12 |
Correct |
469 ms |
185152 KB |
Output is correct |
13 |
Correct |
506 ms |
186504 KB |
Output is correct |
14 |
Correct |
513 ms |
186776 KB |
Output is correct |
15 |
Correct |
447 ms |
185288 KB |
Output is correct |
16 |
Correct |
460 ms |
185712 KB |
Output is correct |
17 |
Correct |
448 ms |
185500 KB |
Output is correct |
18 |
Correct |
512 ms |
184624 KB |
Output is correct |
19 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |