I thought the set set was the strongest, so make a note.
ARC006A Difficulty:238 The problem itself is simple. The key to achieving high performance in competitive professionals is how quickly and smartly you can write!
You can solve it without using set, but this time I will try to solve it using set.
setYou can do something like a Venn diagram in high school math!
ʻA | B: Union ʻA & B: Intersection
ʻA ^ B: Exclusive OR (only one of them is true Bitwise XOR) ʻA-B: Difference set (only in A)
In particular···
test.py
A={1,2,3,5,6}
B={2,4,5,7}
print(A|B)
print(A&B)
print(A^B)
print(A-B)
Output result

set strong (confident)
There seems to be various uses
set, it looks like thistest.py
def I(): return int(input())
def LI(): return list(map(int,input().split()))
E = set(LI()) #Receive as a set!
B = I()
L = set(LI()) #Receive as a set!
ans = 0
count = len(E&L) #Intersection! !! !!
if count==5 and B in L:
ans = 2
else:
ans = {6:1,5:3,4:4,3:5}[count] if count>=3 else 0
print(ans)
If you have the knowledge of this set in mind, you should be able to code this problem in less than 3 minutes! You can solve it without knowing this, but if you know it, you can solve it quickly = I think you can become a strong person.
end!
Recommended Posts