Set Mutations

  • + 0 comments
    a = int(input())
    A = set(map(int, input().split()))
    N = int(input())
    operations = {'intersection_update': A.intersection_update, 'update': A.update, 'symmetric_difference_update': A.symmetric_difference_update, 'difference_update': A.difference_update}
    for _ in range(N):
        name, _ = input().split()
        B = list(map(int, input().split()))
        operations[name](B)
    print(sum(A))