Submission #470971

#TimeUsernameProblemLanguageResultExecution timeMemory
470971iulia13Furniture (JOI20_furniture)C++14
100 / 100
2426 ms12980 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, m; bool SePoate[N][N]; int diag[N + N]; int b = 1; struct ura{ int x, y; }; int verif(int x, int y) { if (x < 1 || y < 1 || n < x || m < y) return 1; return 0; } void upd(int x, int y) { if (verif(x, y) || SePoate[x][y] == false) return; SePoate[x][y] = false; diag[x + y]--; if (verif(x - 1, y + 1) || SePoate[x - 1][y + 1] == false) { upd(x, y + 1); upd(x - 1, y); } if (verif(x + 1, y - 1) || SePoate[x + 1][y - 1] == false) { upd(x, y - 1); upd(x + 1, y); } } int main() { int i, j; cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) SePoate[i][j] = true; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { int nr; cin >> nr; diag[i + j]++; if (nr) upd(i, j); } int q; cin >> q; while(q--) { int x, y; cin >> x >> y; if (SePoate[x][y] == false) { cout << 1 << '\n'; continue; } if (diag[x + y] > 1) { cout << 1 << '\n'; upd(x, y); continue; } cout << 0 << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...