Pagini recente » Cod sursa (job #2988238) | Cod sursa (job #582017) | Cod sursa (job #2132330) | Cod sursa (job #1193054) | Cod sursa (job #2736369)
with open('proc2.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('proc2.out','w') as g:
for i in range(len(out)):
g.write(str(out[i])+'\n')