Skip to content

Instantly share code, notes, and snippets.

@liesen
Created January 16, 2020 22:47
Show Gist options
  • Save liesen/bc59dd3e84707ca0bc94c5e0599f6dd1 to your computer and use it in GitHub Desktop.
Save liesen/bc59dd3e84707ca0bc94c5e0599f6dd1 to your computer and use it in GitHub Desktop.
with open('gymnastics.in', 'r') as fin:
K, N = map(int, fin.readline().split())
P = {k: {int(n): i for i, n in enumerate(fin.readline().split())}
for k in range(K)}
ans = 0
for n1 in range(1, N + 1):
for n2 in range(1, N + 1):
if n1 == n2:
continue
if all(P[k][n1] < P[k][n2] for k in range(K)):
ans += 1
with open('gymnastics.out', 'w') as fout:
print(ans, file=fout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment