제출 #1172992

#제출 시각아이디문제언어결과실행 시간메모리
1172992PetrixFurniture (JOI20_furniture)C++20
100 / 100
139 ms10268 KiB
#include <iostream> using namespace std; int n,m; int v[2002][2002]; int diag[4002]; bool in(int l,int c){ return (l>0 && c>0 && l<=n && c<=m); } void update(int l,int c); void dfs(int l,int c){ if(!v[l+1][c-1]) { update(l,c-1); update(l+1,c); } if(!v[l-1][c+1]) { update(l,c+1); update(l-1,c); } } void update(int l,int c){ ///cout<<l<<" "<<c<<"|"; if(v[l][c]){ diag[l+c]--;v[l][c]=0; dfs(l,c); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i,j,a,b,q; cin>>n>>m; for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ v[i][j]=1;diag[i+j]++; } } for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ cin>>a; if(a) update(i,j); } } cin>>q; for(i=1;i<=q;i++){ cin>>a>>b; if(v[a][b]==0){ cout<<"1\n"; }else if(diag[a+b]==1){ cout<<"0\n"; }else{ update(a,b); cout<<"1\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...