fork download
  1. def find_color(x, y):
  2. # Determine color based on the rules derived from triangle construction
  3. if x % 2 == 1:
  4. return 1 # Red
  5. else:
  6. return 0 # Blue
  7.  
  8. def main():
  9. import sys
  10. input = sys.stdin.read
  11. data = input().strip().split()
  12.  
  13. Q = int(data[0]) # Number of queries
  14. results = []
  15.  
  16. index = 1
  17. for _ in range(Q):
  18. x = int(data[index])
  19. y = int(data[index + 1])
  20. index += 2
  21. color = find_color(x, y)
  22. results.append(color)
  23.  
  24. # Print all results
  25. print(" ".join(map(str, results)))
  26.  
  27. if __name__ == "__main__":
  28. main()
Success #stdin #stdout 0.04s 9928KB
stdin
6
1 1
5 3
8 2
8 6
5 4
6 4
stdout
1 1 0 0 1 0