#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
int K, C;
bool bad (int x, int y, int k) {
return abs(x - y) > k;
}
bool tb[1005][1005];
void solve (int m, int n) {
if(tb[m][n]) return;
int remaining = K - max(m, n);
tb[m][n] = true;
if(remaining == 0) return;
for(int state = 1; state <= 3; state++) {
int x = m, y = n;
if(state & 1) ++x;
if(x + (remaining - 1) < y || y + remaining < x) {
tb[x][y] = true;
continue;
}
if(state & 2) ++y;
if(x + (remaining - 1) < y || y + (remaining - 1) < x) {
tb[x][y] = true;
continue;
}
solve(x, y);
}
}
int main() {
scanf("%d%d", &K, &C);
solve(0, 0);
while(C--) {
int M, N; scanf("%d%d", &M, &N);
puts(tb[M][N] ? "1" : "0");
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
0 ms |
2068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
0 ms |
2068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
16 ms |
2068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
28 ms |
2068 KB |
Output is correct |
5 |
Correct |
34 ms |
2096 KB |
Output is correct |
6 |
Correct |
43 ms |
2096 KB |
Output is correct |
7 |
Correct |
31 ms |
2092 KB |
Output is correct |
8 |
Correct |
42 ms |
2088 KB |
Output is correct |