jzoj4309 刷題計劃
阿新 • • 發佈:2019-02-05
Description
Input
Output
Sample Input
10000 12
2 1
3
2 9999
3
1 1
3
2 1
3
2 10000
3
2 9999
3
Sample Output
1
9999 1
9999
9999
10000 9999
9999 10000
Data Constraint
演算法討論
n太大了,但m又很小,所以當對了某題目是,在前面的提交了此題的就標記為false,如果後面又提交但沒有ac的就不會受影響。
var
n,m,i,j,l:longint;
x,y,s:array[1..200] of longint;
f:array [1..200] of boolean;
begin
assign(input,'problem.in');reset(input);
assign(output,'problem.out');rewrite(output);
readln(n,m);
fillchar(f,sizeof(f),true);
for i:=1 to m do
begin
read(x[i]);
if x[i]=1 then
begin
readln(y[i]);
f[i]:=false;
for j:=1 to i-1 do
if (f[j])and(y[j]=y[i]) then
f[j]:=false;
end;
if x[i]=2 then
begin
readln(y[i]);
for j:=1 to i-1 do
begin
if (x[j]=1)and(y[i]=y[j]) then
f[i]:=false;
if (x[j]=2 )and(y[i]=y[j]) then
f[j]:=false;
end;
end;
if x[i]=3 then
begin
l:=0;
for j:=i-1 downto 1 do
if (f[j])and(x[j]=2) then
begin
inc(l);
s[l]:=y[j];
if l=20 then break;
end;
for j:=1 to l do
write(s[j],' ');
writeln;
end;
end;
close(input);close(output);
end.