# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
294438 | ChrisT | Furniture (JOI20_furniture) | C++17 | 466 ms | 17920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e3+5, MOD = 1e9 + 7, BASE = 143;
bool canL[MN][MN], canR[MN][MN];
int a[MN][MN], cnt[MN * 2];
int main () {
int n,m;
scanf ("%d %d",&n,&m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf ("%d",&a[i][j]);
canL[i][j] = !a[i][j] && (i*j==1 || canL[i-1][j] || canL[i][j-1]);
}
}
for (int i = n; i >= 1; i--) {
for (int j = m; j >= 1; j--) {
canR[i][j] = !a[i][j] && ((i==n&&j==m)||canR[i+1][j]||canR[i][j+1]);
cnt[i+j] += canR[i][j] && canL[i][j];
}
}
function<void(int,int)> fixL = [&] (int x, int y) {
if (x > n || y > m || !canL[x][y] || (canL[x][y] = canL[x-1][y] || canL[x][y-1])) return;
cnt[x+y] -= canR[x][y];
fixL(x+1,y); fixL(x,y+1);
};
function<void(int,int)> fixR = [&] (int x, int y) {
if (x <= 0 || y <= 0 || !canR[x][y] || (canR[x][y] = canR[x+1][y] || canR[x][y+1])) return;
cnt[x+y] -= canL[x][y];
fixR(x-1,y); fixR(x,y-1);
};
int q; scanf ("%d",&q);
while (q--) {
int x,y;
scanf ("%d %d",&x,&y);
if (!(canL[x][y] && canR[x][y])) {printf ("1\n"); continue;}
if (cnt[x+y] == 1) {printf ("0\n"); continue;}
canL[x][y] = canR[x][y] = 0;
--cnt[x+y];
fixR(x-1,y); fixR(x,y-1);
fixL(x+1,y); fixL(x,y+1);
printf ("1\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |