# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494436 | Christopher_ | Jetpack (COCI16_jetpack) | C++17 | 2 ms | 2508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int m;
cin >> m;
vector<string> g(10);
for (int i = 0; i < 10; ++i) {
cin >> g[i];
}
vector<int> ans;
auto e = [&](int x, int y) {
return x >= 0 && x < 10 && y >= 0 && y < m && g[x][y] != 'X';
};
function<bool(int,int)> Dfs = [&](int x, int y) {
if (x == 0 || y == m - 1) {
return true;
}
if (x == 9) {
int nx = x, ny = y + 1;
if (e(nx, ny)) {
if (Dfs(nx, ny)) {
return true;
}
}
nx = x - 1, ny = y + 1;
if (e(nx, ny)) {
if (Dfs(nx, ny)) {
ans.push_back(ny);
return true;
}
}
} else {
int nx = x - 1, ny = y + 1;
if (e(nx, ny)) {
if (Dfs(nx, ny)) {
ans.push_back(ny);
return true;
}
}
nx = x + 1, ny = y + 1;
if (e(nx, ny)) {
if (Dfs(nx, ny)) {
return true;
}
}
}
return false;
};
if (Dfs(9, 0) == false) {
cout << "0\n";
}
for (int i = (int) ans.size() - 1; ~i; --i) {
cout << ans[i] << ' ' << 1 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |