Pagini recente » Cod sursa (job #222233) | Diferente pentru problema/gminmax intre reviziile 2 si 3 | Cod sursa (job #48916) | Borderou de evaluare (job #1221200) | Cod sursa (job #2736371)
with open('hashuri.in') as f:
x = int(f.readline())
operatii = []
for i in range(x):
operatii.append(tuple([int(x) for x in f.readline().split()]))
print(operatii)
xs = {}
def hashfunction(x):
return (x*25-x*(x+40))%666013
def add(x):
global xs
val = hashfunction(x)
if val not in xs:
xs[val] = x
def remo(x):
global xs
val = hashfunction(x)
if val in xs:
del xs[val]
def intreb(x):
global xs
val = hashfunction(x)
if val in xs:
return 1
return 0
out = []
for i in operatii:
if i[0] == 1:
add(i[1])
elif i[0] == 2:
remo(i[1])
else:
out.append(intreb(i[1]))
with open('hashuri.out','w') as g:
for i in range(len(out)):
g.write(str(out[i])+'\n')