Skip to content

Instantly share code, notes, and snippets.

@thrasibule
Created April 7, 2018 19:05
Show Gist options
  • Save thrasibule/eade9a910f927cbd6a771311d07e3b4c to your computer and use it in GitHub Desktop.
Save thrasibule/eade9a910f927cbd6a771311d07e3b4c to your computer and use it in GitHub Desktop.
def solve(l):
r = sorted(enumerate(l), key=lambda x:x[1])
for i, (sigma, _) in enumerate(r):
if (sigma - i) % 2 != 0:
return i
else:
return "OK"
T = int(input())
for i in range(T):
_ = input()
l = [int(e) for e in input().split()]
print("Case #{}: {}".format(i+1, solve(l)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment