-
Notifications
You must be signed in to change notification settings - Fork 175
/
acm-icpc-team.py
49 lines (37 loc) · 1 KB
/
acm-icpc-team.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
42
43
44
45
46
47
48
49
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'acmTeam' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts STRING_ARRAY topic as parameter.
#
def acmTeam(topic):
most = 0
most_cnt = 0
for i in range(len(topic) - 1):
for j in range(i + 1, len(topic)):
x = sum(t1 == "1" or t2 == "1" for t1, t2 in zip(topic[i], topic[j]))
if x > most:
most = x
most_cnt = 1
elif x == most:
most_cnt += 1
return most, most_cnt
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0])
m = int(first_multiple_input[1])
topic = []
for _ in range(n):
topic_item = input()
topic.append(topic_item)
result = acmTeam(topic)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()