이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M; cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M)); for(auto &v : A) for(auto &x : v) cin >> x;
function<bool(int, int)> dfs = [&](int r, int c) -> bool {
if (r >= N || c >= M) return 0;
if (A[r][c]) return 0;
cout << r << " " << c << nl;
if (r == N-1 && c == M-1) return 1;
return dfs(r+1, c) || dfs(r, c+1);
};
int Q; cin >> Q;
for(int q = 0; q < Q; q++) {
int r, c; cin >> r >> c; --r, --c; A[r][c] = 1;
int res = dfs(0, 0);
cout << res << nl;
A[r][c] ^= !res;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |