fork download
  1. import sys
  2.  
  3.  
  4. def main():
  5. # n = int(input())
  6. # r1, c1 = map(int, input().split())
  7. # r2, c2 = map(int, input().split())
  8.  
  9. input_lines = iter(sys.stdin)
  10. n = int(next(input_lines))
  11. r1, c1 = map(int, next(input_lines).split())
  12. r2, c2 = map(int, next(input_lines).split())
  13.  
  14. # Ensure Blue is on the left side.
  15. if c1 > c2:
  16. c1 = n - c1 + 1
  17. c2 = n - c2 + 1
  18.  
  19. s = c1 + c2
  20. if r1 == r2:
  21. columns_taken1 = s >> 1
  22. blue_win = columns_taken1 > (n >> 1)
  23. else:
  24. # Let's assume Blue is in the top row.
  25. # They go towards each other.
  26. # The question is what to do near the meet point?
  27. diff = c2 - c1
  28. if diff == 0:
  29. blue_win = False
  30. elif diff == 1:
  31. cells_taken1 = max(
  32. diff + 1 + ((n - c2) << 1), # moving right
  33. s - 1 # moving down
  34. )
  35. blue_win = cells_taken1 > n
  36. elif diff & 1:
  37. # Let's calculate how many cells Blue can take if Red moves
  38. # to the left near the meet point:
  39. cells_taken1 = max(
  40. diff + 1 + ((n - c2) << 1), # moving right
  41. s - 1 # moving down
  42. )
  43. # Now let's calculate how many cells Red would take:
  44. cells_taken2 = max(
  45. (n - (s >> 1) - 1) << 1, # moving up
  46. (n << 1) - cells_taken1 # moving left
  47. )
  48. blue_win = cells_taken2 < n
  49. else:
  50. # Let's calculate how many cells Red can take if Blue moves
  51. # to the right near the meet point:
  52. cells_taken2 = max(
  53. ((c1 - 1) << 1) + (diff | 1), # moving left
  54. (n << 1) - s # moving up
  55. )
  56. # Now let's calculate how many cells Blue would take:
  57. cells_taken1 = max(
  58. s - 2, # moving down
  59. (n << 1) - cells_taken2 # moving right
  60. )
  61. blue_win = cells_taken1 > n
  62.  
  63. if blue_win:
  64. print("Blue")
  65. else:
  66. print("Red")
  67.  
  68.  
  69. if __name__ == "__main__":
  70. main()
Success #stdin #stdout 0.12s 14176KB
stdin
3
1 1
2 1
stdout
Red