Submission #312420

#TimeUsernameProblemLanguageResultExecution timeMemory
312420Jarif_RahmanFurniture (JOI20_furniture)C++17
5 / 100
5068 ms2936 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int n, m; vector <vector<bool>> v, bl; bool dfs(int x, int y){ if(x < 0 || x >= n || y < 0 || y >= m) return 0; if(x == n - 1 && y == m - 1) return 1; if(v[x][y]) return 0; if(bl[x][y]) return 0; bl[x][y] = 1; return dfs(x + 1, y) | dfs(x, y + 1); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; v = vector<vector<bool>>(n, vector<bool>(m)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){ bool bll; cin >> bll; v[i][j] = bll; } int q; cin >> q; while(q--){ bl = vector<vector<bool>>(n, vector<bool>(m, 0)); int x, y; cin >> x >> y; x--, y--; v[x][y] = 1; if(dfs(0, 0)) cout << "1\n"; else{ v[x][y] = 0; cout << "0\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...