# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
319976 | 2020-11-07T04:28:57 Z | jamezzz | Furniture (JOI20_furniture) | C++14 | 462 ms | 13028 KB |
#include <bits/stdc++.h> using namespace std; int n, m, q, x, y, c[2005]; bool r[1005][1005]; void dfs(int x, int y); void push(int x, int y){ if (r[x][y]){ r[x][y] = false; --c[x + y]; dfs(x, y); } } int add(int x, int y){ if (!r[x][y]) return 1; //no path through (x, y) if (c[x + y] == 1) return 0; push(x, y); return 1; } void dfs(int x, int y){ if (!r[x - 1][y + 1]){ push(x - 1, y); push(x, y + 1); } if (!r[x + 1][y - 1]){ push(x, y - 1); push(x + 1, y); } } int main(){ scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i){ for (int j = 1; j <= m; ++j){ r[i][j] = true; ++c[i + j]; } } for (int i = 1; i <= n; ++i){ for (int j = 1; j <= m; ++j){ scanf("%d", &x); if (x == 1) add(i, j); } } scanf("%d", &q); for (int i = 0; i < q; ++i){ scanf("%d%d", &x, &y); printf("%d\n", add(x, y)); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Correct | 3 ms | 492 KB | Output is correct |
4 | Correct | 4 ms | 492 KB | Output is correct |
5 | Correct | 5 ms | 492 KB | Output is correct |
6 | Correct | 5 ms | 492 KB | Output is correct |
7 | Correct | 5 ms | 492 KB | Output is correct |
8 | Correct | 5 ms | 492 KB | Output is correct |
9 | Correct | 5 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Correct | 3 ms | 492 KB | Output is correct |
4 | Correct | 4 ms | 492 KB | Output is correct |
5 | Correct | 5 ms | 492 KB | Output is correct |
6 | Correct | 5 ms | 492 KB | Output is correct |
7 | Correct | 5 ms | 492 KB | Output is correct |
8 | Correct | 5 ms | 492 KB | Output is correct |
9 | Correct | 5 ms | 568 KB | Output is correct |
10 | Correct | 17 ms | 888 KB | Output is correct |
11 | Correct | 4 ms | 492 KB | Output is correct |
12 | Correct | 199 ms | 5988 KB | Output is correct |
13 | Correct | 93 ms | 3300 KB | Output is correct |
14 | Correct | 371 ms | 10852 KB | Output is correct |
15 | Correct | 369 ms | 11108 KB | Output is correct |
16 | Correct | 400 ms | 11876 KB | Output is correct |
17 | Correct | 432 ms | 12644 KB | Output is correct |
18 | Correct | 407 ms | 12332 KB | Output is correct |
19 | Correct | 429 ms | 12900 KB | Output is correct |
20 | Correct | 401 ms | 13028 KB | Output is correct |
21 | Correct | 462 ms | 13028 KB | Output is correct |