Pagini recente » Cod sursa (job #1325369) | Cod sursa (job #1860291) | Monitorul de evaluare | Cod sursa (job #446551) | Cod sursa (job #930260)
Cod sursa(job #930260)
var f,g:text;
a:array of array of longint;
bufin,bufout:array[1..65000] of byte;
i,q,x,c,n:longint;
procedure insert(x:longint);
begin
c:=x mod 94721;
inc(a[c,0]);
if a[c,0]=length(a[c]) then
setlength(a[c],length(a[c])*2);
a[c,a[c,0]]:=x;
end;
procedure delete(x:longint);
var i:longint;
begin
c:=x mod 94721;
i:=1;
while i<=a[c,0] do begin
if a[c,i]=x then begin
a[c,i]:=a[c,a[c,0]];
dec(a[c,a[c,0]]);
end;
inc(i);
end;
end;
procedure query(x:longint);
var i:longint;
sem:boolean;
begin
c:=x mod 94721;
sem:=false;
for i:=1 to a[c,0] do
if a[c,i]=x then begin
sem:=true;
break;
end;
if sem then writeln(g,1) else writeln(g,0);
end;
begin
assign(f,'hashuri.in');
assign(g,'hashuri.out');
reset(f);
rewrite(g);
settextbuf(f,bufin);
settextbuf(g,bufout);
setlength(a,94730,1);
readln(f,n);
for i:=1 to n do begin
readln(f,q,x);
if q=1 then insert(x);
if q=2 then delete(x);
if q=3 then query(x);
end;
close(g);
end.