fork(16) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template< template<int, int, int> class _MR, int map, int x, int y, bool visited>
  6. struct GetCount {
  7. enum Result
  8. {
  9. value = _MR<(map | (1 << ( ( x << 2) +y ))), (x-1), y>::value +
  10. _MR<(map | (1 << ( ( x << 2) +y ))), (x+1), y>::value +
  11. _MR<(map | (1 << ( ( x << 2) +y ))), x, (y-1)>::value +
  12. _MR<(map | (1 << ( ( x << 2) +y ))), x, (y+1)>::value
  13. };
  14. };
  15.  
  16. template< template<int, int, int> class _MR, int map, int x, int y>
  17. struct GetCount<_MR, map, x, y, true> {
  18. enum Result
  19. {
  20. value = 0
  21. };
  22. };
  23.  
  24. template <int map, int x, int y>
  25. struct MapRoute {
  26. enum Result { value = GetCount<MapRoute, map, x, y, ( (map & ( 1 << ( (x << 2) +y))) != 0 )>::value };
  27. };
  28.  
  29. template<int map, int y>
  30. struct MapRoute<map, -1, y> {
  31. enum Result { value = 0 };
  32. };
  33.  
  34. template<int map, int y>
  35. struct MapRoute<map, 4, y> {
  36. enum Result { value = 0 };
  37. };
  38.  
  39. template<int map, int x>
  40. struct MapRoute<map, x, -1> {
  41. enum Result { value = 0 };
  42. };
  43.  
  44. template<int map, int x>
  45. struct MapRoute<map, x, 4> {
  46. enum Result { value = 0 };
  47. };
  48.  
  49. template<int map>
  50. struct MapRoute<map, 3, 3> {
  51. enum Result { value = 1 };
  52. };
  53.  
  54. int main(void) {
  55. cout << MapRoute<0, 0, 0>::value << endl;
  56. return 0;
  57. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
184