Submission #1053409

#TimeUsernameProblemLanguageResultExecution timeMemory
1053409kachim2Furniture (JOI20_furniture)C++17
5 / 100
5076 ms6356 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n, m; cin >> n >> m; vector<vector<int>> inp(n+2, vector<int>(m+2, 0)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++ ){ cin >> inp[i][j]; } } int q; cin >> q; for(int _ = 0; _ < q; _++){ int x, y; cin >> x >> y; vector<vector<bool>> p(n+2, vector<bool>(m+2, 0)); p[1][1] = 1; inp[x][y] = 1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++ ){ if(inp[i][j] == 0){ if(i!=1 || j!=1) p[i][j] = p[i-1][j] || p[i][j-1]; } } } if(p[n][m]) { cout << "1\n"; }else{ cout << "0\n"; inp[x][y] = 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...