#include "../../include/aoc.hpp" #include using namespace std; vector tape; // HACK: hardcoded input ll rec(int i, ll a) { for (ll aa = a << 3; aa < (a + 1) << 3; aa++) { ll b = aa & 7; b ^= 1; ll c = aa >> b; b ^= c ^ 4; if ((b & 7) == tape[i]) { if (i == 0) { return aa; } else { ll n = rec(i - 1, aa); if (n != -1) { return n; } } } } return -1; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin.ignore(12); cin >> n; cin.ignore(13); cin >> n; cin.ignore(13); cin >> n; cin.ignore(11); while (cin >> n) { tape.push_back(n); cin.ignore(); } cout << rec(tape.size() - 1, 0) << '\n'; }