// 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5057 ms |
214564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5057 ms |
214564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |