Submission #306778

#TimeUsernameProblemLanguageResultExecution timeMemory
306778MrDominoFurniture (JOI20_furniture)C++14
5 / 100
5101 ms1816 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 2000 + 7; int n; int m; int a[N][N]; int down[N][N]; void full() { down[n + 1][m] = down[n][m + 1] = 1; for (int i = n; i >= 1; i--) { for (int j = m; j >= 1; j--) { if (a[i][j] == 0) { down[i][j] = (down[i + 1][j] > 0) + (down[i][j + 1] > 0); } else { down[i][j] = 0; } } } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } int q; cin >> q; for (int i = 1; i <= q; i++) { int r, c; cin >> r >> c; a[r][c] = 1; full(); if (down[1][1] == 0) { a[r][c] = 0; cout << "0\n"; } else { cout << "1\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...