-
-
Save kierendavies/5391400 to your computer and use it in GitHub Desktop.
Google Code Jam 2013 Qualification Round Problem B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from itertools import product | |
T = int(input()) | |
for t in range(T): | |
N, M = list(map(int, input().split())) | |
grid = [list(map(int, input().split())) for n in range(N)] | |
rowmax = list(map(max, grid)) | |
colmax = list(map(max, map(list, zip(*grid)))) | |
for n, m in product(range(N), range(M)): | |
if grid[n][m] != rowmax[n] and grid[n][m] != colmax[m]: | |
print("Case #{}: NO".format(t + 1)) | |
break | |
else: | |
print("Case #{}: YES".format(t + 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment