Submission #651093

#TimeUsernameProblemLanguageResultExecution timeMemory
651093tuanvip870Jetpack (COCI16_jetpack)C++14
80 / 80
111 ms10708 KiB
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef pair <int, int> ii;
#define file "TEST"
#define st first
#define nd second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define vll vector<ll>
#define vi vector<int>
#define all(v) (v).begin(), (v).end()
#define FOR(i,x,y) for(ll i = x; i <= y; ++i)
#define FOS(i,x,y) for(ll i = x; i >= y; --i)
#define EACH(i,x) for (auto &(i) : (x))
#define el cout << '\n';
const ll MOD = 1e9 + 7;
#define dbg(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]  "
#define dbge(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]" << endl;

/*
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
*/

const int N = 2e5 + 5;;

int n, a[11][N];
vi res;

bool DFS(int i, int j) {
	if (a[i][j]) return 0;
	if (j == n) return 1;
	a[i][j] = 1;

	if (DFS(max(i - 1, 1), j + 1)) {
		res.pb(j - 1);
		return 1;
	}
	if (DFS(min(i + 1, 10), j + 1)) return 1;
	return 0;
}

void solve() {
	cin >> n;
	FOR(i, 1, 10) {
		FOR(j, 1, n) {
			char c; cin >> c;
			if (c == 'X') a[i][j] = 1;
		}
	}

	DFS(10, 1);

	cout << res.size() << '\n';
	FOS(i, res.size() - 1, 0) cout << res[i] << " 1" << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen(file".INP","r",stdin);
    //freopen(file".OUT","w",stdout);

    ll t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...