// UVa 824 - Coast Tracker
#include <iostream>
using namespace std;
struct triad {
int x, y, z;
};
bool wall[8];
int dir[3][3] = { { 3, 2, 1 }, { 4, -1, 0 }, { 5, 6, 7 } };
int to_dir(triad a, triad b) {
return dir[a.x - b.x + 1][a.y - b.y + 1];
}
int main() {
triad r;
while (cin >> r.x >> r.y >> r.z && (r.x != -1)) {
// read surroundings
for (int i = 0; i < 8; i++) {
triad a;
cin >> a.x >> a.y >> a.z;
wall[to_dir(a, r)] = (a.z == 0);
}
// determine next move
int d = (r.z + 5) % 8, sol;
for (int i = 0; i < 8; i++) {
int dd = (d + i) % 8;
if (!wall[dd]){
sol = dd;
break;
}
}
cout << sol << endl;
}
return 0;
}
Friday, June 12, 2015
UVa 824 - Coast Tracker
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment