#include<bits/stdc++.h>
using namespace std;
int K,T;
bool AB[1001][1001];
void ABK(int A,int B,int K)
{
if(A+K<B||B+K<A||K==0){if(!(A+K+1<B||B+K+2<A))AB[A][B]=1;return;}
ABK(A+1,B,K-1);
ABK(A+1,B+1,K-1);
ABK(A,B+1,K-1);
ABK(A,B,K-1);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>K>>T;
ABK(0,0,K);
for(;T--;)
{
int A,B;
cin>>A>>B;
printf("%d\n",AB[A][B]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
456 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
764 KB |
Output is correct |
3 |
Correct |
3 ms |
896 KB |
Output is correct |
4 |
Correct |
3 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
896 KB |
Output is correct |
2 |
Correct |
2 ms |
896 KB |
Output is correct |
3 |
Correct |
8 ms |
896 KB |
Output is correct |
4 |
Correct |
35 ms |
1396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
1396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |