-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathacm-icpc-team.py
43 lines (35 loc) · 950 Bytes
/
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
# ACM ICPC Team
# Print the maximum topics a given team can cover for ACM ICPC World Finals
#
# https://www.hackerrank.com/challenges/acm-icpc-team/problem
#
import itertools
def acmTeam(topic):
# Complete this function
bt = [int(i, 2) for i in topic]
def count_bits(i):
return bin(i).count('1')
# n = 0
# while i != 0:
# i, r = divmod(i, 2)
# n += r
# return n
bmax = 0
bmax_count = 0
for i, j in itertools.combinations(bt, 2):
b = count_bits(i | j)
if b > bmax:
bmax = b
bmax_count = 1
elif b == bmax:
bmax_count += 1
return bmax, bmax_count
if __name__ == "__main__":
n, m = map(int, input().split())
topic = []
topic_i = 0
for topic_i in range(n):
topic_t = input().strip()
topic.append(topic_t)
result = acmTeam(topic)
print ("\n".join(map(str, result)))