Submission #496053

#TimeUsernameProblemLanguageResultExecution timeMemory
496053minhcoolFurniture (JOI20_furniture)C++17
0 / 100
918 ms524292 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 105; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, m, c[N][N], q; bool ck(){ queue<ii> bfs; bfs.push({1, 1}); while(!bfs.empty()){ ii u = bfs.front(); bfs.pop(); if(u == make_pair(n, m)) return 1; if(u.se != m && c[u.fi][u.se + 1] == 0) bfs.push({u.fi, u.se + 1}); if(u.fi != n && c[u.fi + 1][u.se] == 0) bfs.push({u.fi + 1, u.se}); } return 0; } void process(){ 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; if(!ck()){ cout << 0 << "\n"; c[x][y] = 0; } else cout << 1 << "\n"; } } signed main(){ ios_base::sync_with_stdio(0); process(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...