You are viewing a single comment's thread. Return to all comments →
n = int(input()) A = set(map(int, input().split()))
S = int(input())
for i in range(S): Choice = input().split() N = set(map(int, input().split())) if Choice[0] == "intersection_update": A.intersection_update(N) elif Choice[0] == "update": A.update(N) elif Choice[0] == "symmetric_difference_update": A.symmetric_difference_update(N) elif Choice[0] == "difference_update": A.difference_update(N)
print(sum(A))
Seems like cookies are disabled on this browser, please enable them to open this website
Set Mutations
You are viewing a single comment's thread. Return to all comments →
n = int(input()) A = set(map(int, input().split()))
S = int(input())
for i in range(S): Choice = input().split() N = set(map(int, input().split())) if Choice[0] == "intersection_update": A.intersection_update(N) elif Choice[0] == "update": A.update(N) elif Choice[0] == "symmetric_difference_update": A.symmetric_difference_update(N) elif Choice[0] == "difference_update": A.difference_update(N)
print(sum(A))