fork download
  1. #include <cstdint>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. using U64 = uint64_t;
  6.  
  7. const int X = 3;
  8. const int Y = 152;
  9. const int XY = X*Y;
  10.  
  11. const U64 evenmask = 0x5555555555555555UL;
  12. const U64 oddmask = ~evenmask;
  13.  
  14. U64 trees[XY];
  15. U64 hats[XY];
  16. int wolfx, wolfy;
  17.  
  18. void init() {
  19. for(int i = 0; i < XY; ++i) {
  20. trees[i] = i;
  21. hats[i] = i;
  22. }
  23. }
  24.  
  25. void wolf() {
  26. hats[wolfy*X + wolfx/64] &= ~(1 << (wolfx % 64));
  27. }
  28.  
  29. void step(int t) {
  30. for (int i = X; i < XY-X; ++i) {
  31. U64 h = hats[i];
  32. h &= ((t + i/3) % 2) ? oddmask : evenmask;
  33. h |= h << 1 | h >> 1 | (hats[i+1]>>63) | (hats[i-1]<<63) | hats[i-X] | hats[i+X];
  34. hats[i] = h;
  35. }
  36. }
  37.  
  38. int main() {
  39. init();
  40. wolfx = 1; wolfy = 2;
  41. for (int t = 0; t < 32000; ++t) {
  42. wolf();
  43. wolfx = (wolfx + 1) % 3;
  44. wolfy = (wolfy + 1) % 100;
  45. wolf();
  46. step(t);
  47. }
  48. cout << hats[X];
  49. }
  50.  
Success #stdin #stdout 0.07s 3472KB
stdin
Standard input is empty
stdout
18446744073709551615