Submission #494436

#TimeUsernameProblemLanguageResultExecution timeMemory
494436Christopher_Jetpack (COCI16_jetpack)C++17
0 / 80
2 ms2508 KiB
#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 timeMemoryGrader output
Fetching results...