# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
599381 | jmyszka2007 | Furniture (JOI20_furniture) | C++17 | 5077 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool to[1010][1010];
bool from[1010][1010];
int cnt[2010];
int meb[1010][1010];
int n, m;
void dfst(int x, int y) {
if(x > n || y > m) {
return;
}
to[x][y] = 0;
if(!to[x - 1][y + 1]) {
dfst(x + 1, y);
}
if(!to[x + 1][y - 1]) {
dfst(x, y + 1);
}
if(from[x][y]) {
cnt[x + y]--;
}
}
void dfsf(int x, int y) {
if(x < 1 || y < 1) {
return;
}
from[x][y] = 0;
if(!from[x - 1][y + 1]) {
dfsf(x - 1, y);
}
if(!from[x + 1][y - 1]) {
dfsf(x, y - 1);
}
if(to[x][y]) {
cnt[x + y]--;
}
}
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
scanf("%d", &meb[i][j]);
}
}
to[1][1] = 1;
from[n][m] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(!meb[i][j]) {
if(to[i - 1][j] || to[i][j - 1]) {
to[i][j] = 1;
}
}
}
}
for(int i = n; i >= 1; i--) {
for(int j = m; j >= 1; j--) {
if(!meb[i][j]) {
if(from[i + 1][j] || from[i][j + 1]) {
from[i][j] = 1;
}
}
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(to[i][j] && from[i][j]) {
cnt[i + j]++;
}
}
}
int t;
scanf("%d", &t);
while(t--) {
int a, b;
scanf("%d%d", &a, &b);
if(cnt[a + b] > 1 || !to[a][b] || !from[a][b]) {
printf("%d\n", 1);
dfst(a, b);
dfsf(a, b);
}
else {
printf("%d\n", 0);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |