-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.py
41 lines (31 loc) · 951 Bytes
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/python
import os
def organizingContainers(container):
num_of_types = []
num_in_conts = []
size = len(container)
for i in range(size):
of_type = 0
in_cont = 0
for j in range(size):
of_type += container[i][j]
in_cont += container[j][i]
num_of_types.append(of_type)
num_in_conts.append(in_cont)
print(sorted(num_in_conts))
print(sorted(num_of_types))
if sorted(num_in_conts) == sorted(num_of_types):
return 'Possible'
else:
return 'Impossible'
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(raw_input())
for q_itr in xrange(q):
n = int(raw_input())
container = []
for _ in xrange(n):
container.append(map(int, raw_input().rstrip().split()))
result = organizingContainers(container)
fptr.write(result + '\n')
fptr.close()