Pagini recente » Cod sursa (job #2060588) | Cod sursa (job #2150695) | Cod sursa (job #1221675) | Cod sursa (job #1907432) | Cod sursa (job #512503)
Cod sursa(job #512503)
type lista=^element;
element=record
i:longint;
a:lista;
end;
var v:array[1..666013] of lista;
ct,n,a,b,i:longint;
p:lista;
f,g:text;
function exista:boolean;
var w:lista;
begin
w:=v[b mod ct];
exista:=false;
while w<> nil do begin
if w^.i=b then exista:=true;
w:=w^.a;
end;
end;
begin
assign(f,'hashing.in');reset(f);
assign(g,'hashing.out');rewrite(g);
ct:=666013;
readln(f,n);
for i:=1 to n do begin
readln(f,a,b);
if a=1 then begin
if not exista then begin
new(p);
p^.i:=b;
p^.a:=v[b mod ct];
v[b mod ct]:=p;
end;
end
else
if a=2 then begin
p:=v[b mod ct];
while p<> nil do begin
if p^.i=b then p^.i:=0;
p:=p^.a;
end;
{if p^.i=b then v[b mod ct]:=v[b mod ct]^.a else
while p^.a <> nil do begin
if p^.a^.i=b then p^.a:=p^.a^.a;
p:=p^.a;
end; }
end
else
begin
if exista then writeln(g,1) else writeln(g,0);
end;
end;
close(f);
close(g);
end.