Submission #494808

# Submission time Handle Problem Language Result Execution time Memory
494808 2021-12-16T15:10:16 Z Christopher_ Jetpack (COCI16_jetpack) C++17
80 / 80
14 ms 10972 KB
#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> res;
  function<bool(int,int)> Dfs = [&](int x, int y) {
    if (g[x][y] == 'X') return false;
    if (y == m - 1) return true;
    g[x][y] = 'X';
    if (Dfs(max(0, x - 1), y + 1)) {
      res.push_back(y);
      return true;
    }
    if (Dfs(min(9, x + 1), y + 1)) {
      return true;
    }
    return false;
  };
  if (Dfs(9, 0) == false) {
    cout << "0\n";
  }
  cout << (int) res.size() << '\n';
  for (int i = (int) res.size() - 1; ~i; --i) {
    cout << res[i] << " 1\n";
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 720 KB Output is correct
6 Correct 2 ms 956 KB Output is correct
7 Correct 4 ms 2348 KB Output is correct
8 Correct 10 ms 5576 KB Output is correct
9 Correct 11 ms 8136 KB Output is correct
10 Correct 14 ms 10972 KB Output is correct