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.