#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
bitset<1010> reach[1010], open[1010];
int main(){
cin.tie(0)->sync_with_stdio(0);
int n,m,q;
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
int x;
cin>>x;
open[j][i]=!x;
}
cin>>q;
while(q--){
int a,b;
cin>>a>>b;
open[b][a]=0;
reach[0][1]=1;
for(int i=1;i<=m;i++) {
reach[i]=reach[i-1]&open[i];
for(int j=2;j<=n;j++)
if(open[i][j]&&reach[i][j-1])
reach[i][j]=1;
}
if(reach[m][n]){
cout<<"1\n";
} else cout<<"0\n",open[b][a]=1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
17 ms |
512 KB |
Output is correct |
3 |
Correct |
39 ms |
528 KB |
Output is correct |
4 |
Correct |
93 ms |
560 KB |
Output is correct |
5 |
Correct |
103 ms |
348 KB |
Output is correct |
6 |
Correct |
149 ms |
556 KB |
Output is correct |
7 |
Correct |
127 ms |
572 KB |
Output is correct |
8 |
Correct |
106 ms |
344 KB |
Output is correct |
9 |
Correct |
123 ms |
572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
17 ms |
512 KB |
Output is correct |
3 |
Correct |
39 ms |
528 KB |
Output is correct |
4 |
Correct |
93 ms |
560 KB |
Output is correct |
5 |
Correct |
103 ms |
348 KB |
Output is correct |
6 |
Correct |
149 ms |
556 KB |
Output is correct |
7 |
Correct |
127 ms |
572 KB |
Output is correct |
8 |
Correct |
106 ms |
344 KB |
Output is correct |
9 |
Correct |
123 ms |
572 KB |
Output is correct |
10 |
Correct |
4418 ms |
1108 KB |
Output is correct |
11 |
Correct |
112 ms |
344 KB |
Output is correct |
12 |
Execution timed out |
5071 ms |
2720 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |