8 #define MAX 100 // cheat by pre-inspecting input
11 main (int argc
, char **argv
)
15 rows
= atoi (argv
[1]);
17 bool grid
[2][MAX
+ 2] = { 0 }; // true for trap
20 while ((c
= getchar ()) != '\n') {
22 grid
[0][width
+ 1] = true;
25 for (int i
= 0; i
< rows
; i
++)
26 for (int j
= 1; j
<= width
; j
++) {
29 grid
[!(i
& 1)][j
] = grid
[i
& 1][j
- 1] ^ grid
[i
& 1][j
+ 1];
31 printf ("found %d safe tiles in %d rows\n", safe
, rows
);