HackerRank "Vertical Rooks"

Please note: VROOK cannot go back-ward - that leads to a simple variation to Game of Nim: just XOR.

t = int(input())
for _ in range(t):
    n = int(input())
    # Get input
    p1 = []
    for _ in range(n): p1.append(int(input()))
    p2 = []
    for _ in range(n): p2.append(int(input()))
    # Game of Nim
    nim = 0
    for i in range(n):
        nim ^= abs(p2[i]- p1[i]) - 1
    print ("player-2" if nim != 0 else "player-1")

 

你可能感兴趣的:(HackerRank "Vertical Rooks")