This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |