이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |