记录编号 39212 评测结果 AAAAAAAAAA
题目名称 校草 最终得分 100
用户昵称 Gravatarzhangchi 是否通过 通过
代码语言 Pascal 运行时间 2.982 s
提交时间 2012-07-06 20:26:13 内存使用 11.32 MiB
显示代码纯文本
type
  node=record
         a,b,lc,rc,min,need:longint;
       end;
var
  n,i,j,tot,temp,ans,newl,newr:longint;
  a:array[1..5,1..100000] of longint;
  tree:array[1..400000] of node;
  p:array[1..100000] of boolean;
  function min(x,y:longint):longint;
  begin if x<y then min:=x else min:=y; end;
  procedure sort(num,l,r:longint);
  var
    i,j,t,m:longint;
  begin
    i:=l; j:=r;
    m:=a[num,(l+r) div 2];
    repeat
      while a[num,i]<m do inc(i);
      while a[num,j]>m do dec(j);
      if i<=j then
        begin
          t:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=t;
          t:=a[2,i]; a[2,i]:=a[2,j]; a[2,j]:=t;
          t:=a[3,i]; a[3,i]:=a[3,j]; a[3,j]:=t;
          t:=a[4,i]; a[4,i]:=a[4,j]; a[4,j]:=t;
          t:=a[5,i]; a[5,i]:=a[5,j]; a[5,j]:=t;
          inc(i); dec(j);
        end;
    until i>j;
    if l<j then sort(num,l,j);
    if i<r then sort(num,i,r);
  end;
  procedure maketree(l,r:longint);
  var
    t:longint;
  begin
    inc(tot);
    t:=tot;
    tree[t].a:=l;
    tree[t].b:=r;
    if r>l then
      begin
        tree[t].lc:=tot+1;
        maketree(l,(l+r) div 2);
        tree[t].rc:=tot+1;
        maketree((l+r) div 2+1,r);
      end;
  end;
  procedure down(x:longint);
  var
    l,r:longint;
  begin
    l:=tree[x].lc;
    r:=tree[x].rc;
    tree[l].min:=tree[x].need;
    tree[l].need:=tree[x].need;
    tree[r].min:=tree[x].need;
    tree[r].need:=tree[x].need;
    tree[x].need:=0;
  end;
  procedure add(x,value:longint);
  var
    l,r,m:longint;
  begin
    l:=tree[x].a;
    r:=tree[x].b;
    m:=(l+r) div 2;
    if (newl<=l)and(r<=newr) then
      begin
        tree[x].min:=value;
        tree[x].need:=value;
        exit;
      end;
    if tree[x].need<>0 then down(x);
    if not((l>newr)or(m<newl)) then add(tree[x].lc,value);
    if not((m+1>newr)or(r<newl)) then add(tree[x].rc,value);
    tree[x].min:=min(tree[tree[x].lc].min,tree[tree[x].rc].min);
  end;
  function getmin(x:longint):longint;
  var
    l,r,m,temp:longint;
  begin
    l:=tree[x].a;
    r:=tree[x].b;
    m:=(l+r) div 2;
    if (newl<=l)and(r<=newr) then exit(tree[x].min);
    if tree[x].need<>0 then down(x);
    temp:=maxlongint;
    if not((l>newr)or(m<newl)) then temp:=min(temp,getmin(tree[x].lc));
    if not((m+1>newr)or(r<newl)) then temp:=min(temp,getmin(tree[x].rc));
    exit(temp);
  end;
    procedure work(x,y,z:longint);
    begin
      sort(x,1,n);
      fillchar(tree,sizeof(tree),0); tot:=0;
      maketree(1,n);
      for i:=1 to n do
        begin
          newl:=i; newr:=i;
          add(1,maxlongint);
        end;
      for i:=1 to n do
        begin
          newl:=1; newr:=a[y,i]-1;
          temp:=getmin(1);
          if temp<a[z,i] then p[a[5,i]]:=true;
          newl:=a[y,i]; newr:=a[y,i];
          add(1,a[z,i]);
        end;
    end;
begin
  assign(input,'hjjhvf.in'); reset(input);
  assign(output,'hjjhvf.out'); rewrite(output);
  readln(n);
  for i:=1 to n do
    begin
      readln(a[1,i],a[2,i],a[3,i],a[4,i]);
      a[5,i]:=i;
    end;
  fillchar(p,sizeof(p),false);
  work(1,2,3);
  work(1,2,4);
  work(1,3,4);
  work(2,3,4);
  for i:=1 to n do
    if p[i] then inc(ans);
  writeln(ans);
  for i:=1 to n do
    if p[i] then writeln(i);
  close(input); close(output);
end.