You are viewing a single comment's thread. Return to all comments →
n = input() A = set(map(int, input().split())) num_other_sets = input() for _ in range(int(num_other_sets)): eachset = [input().split()[0], set(map(int, input().split()))] if eachset[0] == "update": A.update(eachset[1]) elif eachset[0] == "intersection_update": A.intersection_update(eachset[1]) elif eachset[0] == "symmetric_difference_update": A.symmetric_difference_update(eachset[1]) elif eachset[0] == "difference_update": A.difference_update(eachset[1])
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 →
Enter your code here. Read input from STDIN. Print output to STDOUT
n = input() A = set(map(int, input().split())) num_other_sets = input() for _ in range(int(num_other_sets)): eachset = [input().split()[0], set(map(int, input().split()))] if eachset[0] == "update": A.update(eachset[1]) elif eachset[0] == "intersection_update": A.intersection_update(eachset[1]) elif eachset[0] == "symmetric_difference_update": A.symmetric_difference_update(eachset[1]) elif eachset[0] == "difference_update": A.difference_update(eachset[1])
print(sum(A))