比赛 20120706 评测结果 ATTTTTTTTA
题目名称 校草 最终得分 20
用户昵称 SnowDancer 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-07-06 11:49:03
显示代码纯文本
program hjjhvf;
var
  value:array[1..100001,1..4] of longint;
  out:array[1..100001] of longint;
  bo:array[1..100001] of boolean;
  next,pre:array[1..100001] of longint;
  n,i,j,k,l,tot,count,f,m:longint;
function search(k:longint):longint;
  begin
    if k>n then exit(n+1);
    if not bo[k] then exit(k);
    next[k]:=search(next[k]);
    exit(next[k]);
  end;
procedure qsort(l,r:longint);
  var
    i,j:longint;
  begin
    i:=l;j:=r;m:=out[(i+j) div 2];
    repeat
      while out[i]<m do inc(i);
      while out[j]>m do dec(j);
      if i<=j then begin
        k:=out[i];out[i]:=out[j];out[j]:=k;
        inc(i);dec(j);
      end;
    until i>j;
    if l<j then qsort(l,j);
    if i<r then qsort(i,r);
  end;
begin
assign(input,'hjjhvf.in');reset(input);
assign(output,'hjjhvf.out');rewrite(output);
  readln(n);
  for i:=1 to n do
    for j:=1 to 4 do
      read(value[i,j]);
  for i:=1 to n do begin
    next[i]:=i+1;
    pre[i]:=i-1;
  end;
  for i:=1 to n do begin
    j:=search(i+1);
    while j<=n do begin
      count:=0;
      for k:=1 to 4 do
        if value[i,k]>value[j,k] then
          inc(count)
        else
          dec(count);
      if count<0 then
        if not bo[j] then begin
          inc(tot); out[tot]:=j;
          next[pre[j]]:=next[j];
          pre[next[j]]:=pre[j];
          bo[j]:=true;
        end;
      if count>0 then
        if not bo[i] then begin
          inc(tot); out[tot]:=i;
          bo[i]:=true;
        end;
      j:=search(j+1);
    end;
  end;
  qsort(1,tot);
  writeln(tot);
  for i:=1 to tot do writeln(out[i]);
close(input);close(output);
end.