#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ma[110][110];
int X[3]={0,1};
int Y[3]={1,0};
int n,m;
bool floyd(int x,int y){
if(x==n-1 && y==m-1) return 1;
for(int k=0;k<2;k++){
int xi=x+X[k];
int yi=y+Y[k];
if(yi<m && xi<n && ma[xi][yi]!=1 && floyd(xi,yi)) return 1;
}
return 0;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>ma[i][j];
int q;
cin>>q;
for(int i=0;i<q;i++){
int a,b;
cin>>a>>b;
a--; b--;
ma[a][b]=1;
if(floyd(0,0)) cout<<"1\n";
else{
cout<<"0\n";
ma[a][b]=0;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
419 ms |
332 KB |
Output is correct |
2 |
Execution timed out |
5028 ms |
304 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
419 ms |
332 KB |
Output is correct |
2 |
Execution timed out |
5028 ms |
304 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |