# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
296138 | 2020-09-10T10:20:36 Z | Pyqe | Furniture (JOI20_furniture) | C++14 | 459 ms | 3320 KB |
#include <bits/stdc++.h> using namespace std; long long n,m,fq[2069],vy[4]={-1,0,1,0},vx[4]={0,1,0,-1}; bitset<1069> a[1069]; void dfs(long long y,long long x) { long long im,yy,xx; a[y][x]=1; fq[y+x]--; for(im=0;im<4;im++) { yy=y+vy[im]; xx=x+vx[im]; if(!(yy==1&&xx==1)&&!(yy==n&&xx==m)&&!a[yy][xx]&&((a[yy-1][xx]&&a[yy][xx-1])||(a[yy+1][xx]&&a[yy][xx+1]))) { dfs(yy,xx); } } } int main() { long long t,rr,i,j,k,l,z; scanf("%lld%lld",&n,&m); for(i=0;i<=n+1;i++) { for(j=0;j<=m+1;j++) { a[i][j]=!i||i==n+1||!j||j==m+1; } } for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%lld",&k); if(k&&!a[i][j]) { dfs(i,j); } fq[i+j]++; } } scanf("%lld",&t); for(rr=0;rr<t;rr++) { scanf("%lld%lld",&k,&l); if(a[k][l]||fq[k+l]-1) { if(!a[k][l]) { dfs(k,l); } z=1; } else { z=0; } printf("%lld\n",z); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 6 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 6 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
10 | Correct | 15 ms | 640 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 220 ms | 1656 KB | Output is correct |
13 | Correct | 109 ms | 1176 KB | Output is correct |
14 | Correct | 388 ms | 2680 KB | Output is correct |
15 | Correct | 394 ms | 2808 KB | Output is correct |
16 | Correct | 435 ms | 3192 KB | Output is correct |
17 | Correct | 441 ms | 3064 KB | Output is correct |
18 | Correct | 437 ms | 3064 KB | Output is correct |
19 | Correct | 459 ms | 3312 KB | Output is correct |
20 | Correct | 431 ms | 3320 KB | Output is correct |
21 | Correct | 435 ms | 3192 KB | Output is correct |