-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc190_c.py
More file actions
97 lines (88 loc) · 2.32 KB
/
abc190_c.py
File metadata and controls
97 lines (88 loc) · 2.32 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
abc190_c.py
#####################################
#####################################
#####################################
#####################################
#####################################
#####################################
#####################################
[AC, cGPT created]
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]
K = int(input())
C = [list(map(int, input().split())) for _ in range(K)]
ANS = 0
for i in range(1 << K):
T = [C[j][0] if (i >> j) & 1 == 0 else C[j][1] for j in range(K)]
ans = sum(1 for a in A if all(x in T for x in a))
ANS = max(ANS, ans)
print(ANS)
#####################################
[AC, cGPT fix my cords]
[##### if (i >> j) & 1 == 0: #####]
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]
K = int(input())
C = [list(map(int, input().split())) for _ in range(K)]
ANS = 0
for i in range(1 << K):
T = []
ans = 0
for j in range(K): # 修正点
if (i >> j) & 1 == 0: # 修正点
T.append(C[j][0]) # 修正点
else:
T.append(C[j][1]) # 修正点
for a in A:
if a[0] in T and a[1] in T:
ans += 1
ANS = max(ANS, ans)
print(ANS)
#####################################
[AC, cGPT fix my cords]
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]
K = int(input())
C = [list(map(int, input().split())) for _ in range(K)]
ANS = 0
for i in range(1 << K):
T = []
ans = 0
bit_string = bin(i)[2:].zfill(K) # ビット列を K 桁に拡張
for j, b in enumerate(bit_string):
if b == '0':
T.append(C[j][0])
else:
T.append(C[j][1])
for a in A:
if a[0] in T and a[1] in T:
ans += 1
ANS = max(ANS, ans)
print(ANS)
#####################################
[My WA]
N,M=map(int,input().split())
A=[]
for i in range(M):
a,b=map(int,input().split())
A+=[[a,b]]
K=int(input())
C=[]
for i in range(K):
c,d=map(int,input().split())
C+=[[c,d]]
ANS=0
for i in range(1<<K):
T=[]
ans=0
for j,b in enumerate(list(bin(i)[2:])):
if b=='0':
T+=[C[j][0]]
else:
T+=[C[j][1]]
for a in A:
if a[0] in T and a[1] in T:
ans+=1
ANS=max(ANS,ans)
print(ANS)
#####################################