제출 #1255418

#제출 시각아이디문제언어결과실행 시간메모리
1255418Seyyed_Mojtaba_MortazaviFurniture (JOI20_furniture)C++20
5 / 100
5084 ms940 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; int c[MAXN][MAXN]; bool dp[MAXN][MAXN]; signed main() { int n, m, q; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> c[i][j]; } } cin >> q; while (q--) { int x, y; cin >> x >> y; c[x][y] = 1; dp[1][1] = true; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i == 1 && j == 1) continue; dp[i][j] = false; if (i > 1) dp[i][j] |= dp[i - 1][j]; if (j > 1) dp[i][j] |= dp[i][j - 1]; if (c[i][j] == 1) dp[i][j] = false; } } if (dp[n][m]) { cout << 1 << endl; } else { c[x][y] = 0; cout << 0 << endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...