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