jzoj4309 刷题计划

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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值