//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
//#define _int __int128
//#define int long long
int n;int m;int Q;
int gr[1010][1010];
int ok[1010][1010];
void solve(int a,int b){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
ok[i][j]=0;
}
}
ok[1][1]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(gr[i][j]==1){continue;}
ok[i][j]|=ok[i-1][j]|ok[i][j-1];
}
}
if(ok[n][m]){
cout<<"1\n";
}else{
cout<<"0\n";
gr[a][b]=0;
}
}
signed main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>gr[i][j];
}
}
cin>>Q;
for(int i=1;i<=Q;i++){
int a;int b;
cin>>a>>b;
gr[a][b]=1;
solve(a,b);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4700 KB |
Output is correct |
2 |
Correct |
28 ms |
6608 KB |
Output is correct |
3 |
Correct |
69 ms |
6748 KB |
Output is correct |
4 |
Correct |
162 ms |
6836 KB |
Output is correct |
5 |
Correct |
180 ms |
7088 KB |
Output is correct |
6 |
Correct |
220 ms |
6748 KB |
Output is correct |
7 |
Correct |
146 ms |
6744 KB |
Output is correct |
8 |
Correct |
199 ms |
6992 KB |
Output is correct |
9 |
Correct |
136 ms |
6848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4700 KB |
Output is correct |
2 |
Correct |
28 ms |
6608 KB |
Output is correct |
3 |
Correct |
69 ms |
6748 KB |
Output is correct |
4 |
Correct |
162 ms |
6836 KB |
Output is correct |
5 |
Correct |
180 ms |
7088 KB |
Output is correct |
6 |
Correct |
220 ms |
6748 KB |
Output is correct |
7 |
Correct |
146 ms |
6744 KB |
Output is correct |
8 |
Correct |
199 ms |
6992 KB |
Output is correct |
9 |
Correct |
136 ms |
6848 KB |
Output is correct |
10 |
Correct |
4182 ms |
5264 KB |
Output is correct |
11 |
Correct |
154 ms |
4768 KB |
Output is correct |
12 |
Execution timed out |
5026 ms |
10380 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |