Cod sursa(job #2615654)

Utilizator MARIAN.DANAILADanaila Marian MARIAN.DANAILA Data 15 mai 2020 08:55:11
Problema Hashuri Scor 30
Compilator py Status done
Runda Arhiva educationala Marime 0.6 kb
with open("hashuri.in", "r") as fin:
    with open("hashuri.out", "w") as fout:
        n = int(fin.readline())
        dct = {}
        for i in range(n):
            op, x = [int(s) for s in fin.readline().split(" ")]
            if op == 1:
                dct.update({x: 1})
            elif op == 2:
                try:
                    dct.pop(x)
                except KeyError:
                    continue
            else:
                try:
                    if dct[x] == 1:
                        fout.write("1"+'\n')
                except KeyError:
                    fout.write("0"+'\n')