47 lines
680 B
C++
47 lines
680 B
C++
#include "../../include/aoc.hpp"
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
vector<int> tape;
|
|
|
|
// HACK: hardcoded input
|
|
ll rec(int i, ll a) {
|
|
for (ll aa = a; aa < a + 8; 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 << 3);
|
|
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';
|
|
}
|