#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=80;
int s;
bool vis[N][N][N][N][2],dp[N][N][N][N][2];
bool rec(int i,int j,int k,int l,bool h){
if (i<=0) return h;
if (k<=0) return !h;
if (vis[i][j][k][l][h]) return dp[i][j][k][l][h];
vis[i][j][k][l][h]=1;
if (!h){
if (l) dp[i][j][k][l][h]|=!rec(i,j,k,l-1,1);
if (i-s*l>0) dp[i][j][k][l][h]|=!rec(i,j,k-i+s*l,l,1);
}
else{
if (j) dp[i][j][k][l][h]|=!rec(i,j-1,k,l,0);
if (k-s*j>0) dp[i][j][k][l][h]|=!rec(i-k+s*j,j,k,l,0);
}
return dp[i][j][k][l][h];
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int T;cin>>s>>T;
while (T--){
int ch,fh,cg,fg;
cin>>ch>>fh>>cg>>fg;
if (rec(ch,fh,cg,fg,0)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Runtime error |
3 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
934 ms |
150064 KB |
Output is correct |
12 |
Correct |
650 ms |
149876 KB |
Output is correct |
13 |
Correct |
426 ms |
150224 KB |
Output is correct |
14 |
Correct |
570 ms |
149332 KB |
Output is correct |
15 |
Correct |
213 ms |
148564 KB |
Output is correct |
16 |
Correct |
224 ms |
149364 KB |
Output is correct |
17 |
Correct |
275 ms |
149012 KB |
Output is correct |
18 |
Correct |
792 ms |
148756 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 |
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 |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
934 ms |
150064 KB |
Output is correct |
12 |
Correct |
650 ms |
149876 KB |
Output is correct |
13 |
Correct |
426 ms |
150224 KB |
Output is correct |
14 |
Correct |
570 ms |
149332 KB |
Output is correct |
15 |
Correct |
213 ms |
148564 KB |
Output is correct |
16 |
Correct |
224 ms |
149364 KB |
Output is correct |
17 |
Correct |
275 ms |
149012 KB |
Output is correct |
18 |
Correct |
792 ms |
148756 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 |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
934 ms |
150064 KB |
Output is correct |
12 |
Correct |
650 ms |
149876 KB |
Output is correct |
13 |
Correct |
426 ms |
150224 KB |
Output is correct |
14 |
Correct |
570 ms |
149332 KB |
Output is correct |
15 |
Correct |
213 ms |
148564 KB |
Output is correct |
16 |
Correct |
224 ms |
149364 KB |
Output is correct |
17 |
Correct |
275 ms |
149012 KB |
Output is correct |
18 |
Correct |
792 ms |
148756 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 |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
880 ms |
150104 KB |
Output is correct |
12 |
Correct |
684 ms |
149924 KB |
Output is correct |
13 |
Correct |
383 ms |
150352 KB |
Output is correct |
14 |
Correct |
516 ms |
149224 KB |
Output is correct |
15 |
Correct |
202 ms |
148564 KB |
Output is correct |
16 |
Correct |
212 ms |
149328 KB |
Output is correct |
17 |
Correct |
288 ms |
149076 KB |
Output is correct |
18 |
Correct |
825 ms |
148876 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 |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
979 ms |
150204 KB |
Output is correct |
3 |
Correct |
650 ms |
149908 KB |
Output is correct |
4 |
Correct |
419 ms |
150284 KB |
Output is correct |
5 |
Correct |
565 ms |
149408 KB |
Output is correct |
6 |
Correct |
231 ms |
148760 KB |
Output is correct |
7 |
Correct |
244 ms |
149260 KB |
Output is correct |
8 |
Correct |
272 ms |
148816 KB |
Output is correct |
9 |
Correct |
891 ms |
148640 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
934 ms |
150064 KB |
Output is correct |
12 |
Correct |
650 ms |
149876 KB |
Output is correct |
13 |
Correct |
426 ms |
150224 KB |
Output is correct |
14 |
Correct |
570 ms |
149332 KB |
Output is correct |
15 |
Correct |
213 ms |
148564 KB |
Output is correct |
16 |
Correct |
224 ms |
149364 KB |
Output is correct |
17 |
Correct |
275 ms |
149012 KB |
Output is correct |
18 |
Correct |
792 ms |
148756 KB |
Output is correct |
19 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |