import sys
test_cases = open(sys.argv[1], 'r')
matrix = [[0 for x in range(256)] for x in range(256)]
for test in test_cases:
query = test.split()
command = query[0]
index = int(query[1])
if command == "SetRow":
value=int(query[2])
for i in range(256):
matrix[index][i] = value
elif command == "SetCol":
value=int(query[2])
for i in range(256):
matrix[i][index] = value
elif command == "QueryRow":
sum=0
for i in range(256):
sum += matrix[index][i]
print sum
elif command == "QueryCol":
sum=0
for i in range(256):
sum += matrix[i][index]
print sum
test_cases.close()
test_cases = open(sys.argv[1], 'r')
matrix = [[0 for x in range(256)] for x in range(256)]
for test in test_cases:
query = test.split()
command = query[0]
index = int(query[1])
if command == "SetRow":
value=int(query[2])
for i in range(256):
matrix[index][i] = value
elif command == "SetCol":
value=int(query[2])
for i in range(256):
matrix[i][index] = value
elif command == "QueryRow":
sum=0
for i in range(256):
sum += matrix[index][i]
print sum
elif command == "QueryCol":
sum=0
for i in range(256):
sum += matrix[i][index]
print sum
test_cases.close()
No comments:
Post a Comment