제출 #516503

#제출 시각아이디문제언어결과실행 시간메모리
516503leinad2Furniture (JOI20_furniture)C++17
0 / 100
2 ms2236 KiB
#include<bits/stdc++.h> using namespace std; int n, m, i, j, k, a, b, q, A[1010][1010], vis[1010][1010], chk[1010][1010], B[2010], C[1010][1010], D[1010][1010]; bool dfs(int a, int b) { if(chk[a][b])return vis[a][b]; chk[a][b]=1; if(a==n&&b==m)return vis[a][b]=1; if(a<n&&A[a+1][b]==0&&dfs(a+1, b))vis[a][b]=1,C[a+1][b]=1; if(b<m&&A[a][b+1]==0&&dfs(a, b+1))vis[a][b]=1,D[a][b+1]=1; return vis[a][b]; } void dfs2(int a, int b) { vis[a][b]=0; B[a+b]--; if(D[a+1][b]==0&&vis[a+1][b]==1)dfs2(a+1, b); if(C[a][b+1]==0&&vis[a][b+1]==1)dfs2(a, b+1); } main() { for(scanf("%d %d", &n, &m);i++<n;)for(j=0;j++<m;)scanf("%d", &A[i][j]); dfs(1, 1); for(i=0;i++<n;)for(j=0;j++<m;)B[i+j]+=vis[i][j]; for(scanf("%d", &q);q--;) { scanf("%d %d", &a, &b); if(vis[a][b]==0) { puts("1"); A[a][b]=1; } else { if(B[a+b]!=1) { puts("1"); A[a][b]=1; dfs2(a, b); } else puts("0"); } } }

컴파일 시 표준 에러 (stderr) 메시지

furniture.cpp: In function 'bool dfs(int, int)':
furniture.cpp:8:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    8 |     if(a==n&&b==m)return vis[a][b]=1;
      |                          ~~~~~~~~~^~
furniture.cpp: At global scope:
furniture.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main()
      | ^~~~
furniture.cpp: In function 'int main()':
furniture.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     for(scanf("%d %d", &n, &m);i++<n;)for(j=0;j++<m;)scanf("%d", &A[i][j]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
furniture.cpp:23:59: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     for(scanf("%d %d", &n, &m);i++<n;)for(j=0;j++<m;)scanf("%d", &A[i][j]);
      |                                                      ~~~~~^~~~~~~~~~~~~~~~
furniture.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     for(scanf("%d", &q);q--;)
      |         ~~~~~^~~~~~~~~~
furniture.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...