#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
vector<vector<char>> a;
vector<ll> res;
ll dfs(ll i, ll j){
if (a[i][j]=='X') return 0;
if (j==n-1) return 1;
a[i][j] = 'X';
if (dfs(min(9LL, i+1), j+1)) return 1;
if (dfs(max(0LL, i-1), j+1)) {
res.push_back(j);
return 1;
}
return 0;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
a.assign(10, vector<char>(n+1));
for (int i=0; i<10; i++){
for (int j=0; j<n; j++){
cin >> a[i][j];
}
}
dfs(9,0);
reverse(res.begin(), res.end());
cout << res.size() << endl;
for (auto i : res) cout << i << " " << 1 << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |