You are viewing a single comment's thread. Return to all comments →
n = int(input()) s = set(map(int,input().split())) its = int(input()) for i in range(its): ops = input().split() opn = ops[0] opt = int(ops[1]) ms = set(map(int,input().split())) if opn == "update": s.update(ms) elif opn == "intersection_update": s.intersection_update(ms) elif opn == "symmetric_difference_update": s.symmetric_difference_update(ms) else: s.difference_update(ms)
print(sum(s))
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()) s = set(map(int,input().split())) its = int(input()) for i in range(its): ops = input().split() opn = ops[0] opt = int(ops[1]) ms = set(map(int,input().split())) if opn == "update": s.update(ms) elif opn == "intersection_update": s.intersection_update(ms) elif opn == "symmetric_difference_update": s.symmetric_difference_update(ms) else: s.difference_update(ms)
print(sum(s))