Submission #757579

#TimeUsernameProblemLanguageResultExecution timeMemory
757579HanksburgerFurniture (JOI20_furniture)C++17
5 / 100
5022 ms10148 KiB
#include <bits/stdc++.h> using namespace std; pair<int, int> p[2]={{1, 0}, {0, 1}}; int a[1005][1005], visited[1005][1005]; queue<pair<int, int> > q; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, o; cin >> n >> m; for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin >> a[i][j]; cin >> o; for (int i=1; i<=o; i++) { int x, y; cin >> x >> y; a[x][y]=1; for (int j=1; j<=n; j++) for (int k=1; k<=m; k++) visited[j][k]=0; visited[1][1]=1; q.push({1, 1}); while (!q.empty()) { int ux=q.front().first, uy=q.front().second; q.pop(); // cout << "ux uy " << ux << ' ' << uy << '\n'; for (int j=0; j<2; j++) { int vx=ux+p[j].first, vy=uy+p[j].second; if (1<=vx && vx<=n && 1<=vy && vy<=m && !visited[vx][vy] && !a[vx][vy]) { visited[vx][vy]=1; q.push({vx, vy}); } } } if (!visited[n][m]) a[x][y]=0; cout << a[x][y] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...