제출 #1203759

#제출 시각아이디문제언어결과실행 시간메모리
1203759vicvicFurniture (JOI20_furniture)C++20
0 / 100
1 ms1092 KiB
#include <iostream> #include <fstream> #include <algorithm> using namespace std; const int NMAX=1e3; int n, m, mat[NMAX+5][NMAX+5], viz[NMAX+5][NMAX+5], diag[NMAX*2+5]; void block (int x, int y) { diag[x+y]--; viz[x][y]=0; if (!viz[x+1][y-1] && viz[x+1][y]) block (x+1, y); if (!viz[x+1][y-1] && viz[x][y-1]) block (x, y-1); if (!viz[x-1][y+1] && viz[x-1][y]) block (x-1, y); if (!viz[x-1][y+1] && viz[x][y+1]) block (x, y+1); } int main () { ios_base :: sync_with_stdio (0); cin.tie (nullptr); cin >> n >> m; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { diag[i+j]++; viz[i][j]=1; } } for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { cin >> mat[i][j]; if (mat[i][j]) block (i, j); } } int q; cin >> q; while (q--) { int x, y; cin >> x >> y; if (!viz[x][y]) cout << "1\n"; else if (diag[x+y]==1) cout << "0\n"; else cout << "1\n", block (x, y); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...