#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 time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |