记录编号 39208 评测结果 AAAAAAAAAA
题目名称 校草 最终得分 100
用户昵称 Gravatarwo shi 刘畅 是否通过 通过
代码语言 Pascal 运行时间 1.078 s
提交时间 2012-07-06 18:12:53 内存使用 65.97 MiB
显示代码纯文本
var
  n,i,top:longint;
  v:array[0..1000000]of boolean;
  f,a,b,c,p,q:array[0..1000000]of longint;
  x:array[0..10,0..1000000]of longint;

function lowbit(x:longint):longint;
begin
  lowbit:=x and (-x);
end;

function min(x,y:longint):longint;
begin
  if x<y then min:=x
  else min:=y;
end;

function minnum(k:longint):longint;
var
  num:longint;
begin
  num:=maxlongint;
  while k>0 do
  begin
    num:=min(num,f[k]);
    dec(k,lowbit(k));
  end;
  minnum:=num;
end;

procedure change(k,x:longint);
begin
  while k<=n do
  begin
    f[k]:=min(f[k],x);
    inc(k,lowbit(k));
  end;
end;

procedure swap(var x,y:longint);
var
  z:longint;
begin
  z:=x;
  x:=y;
  y:=z;
end;

procedure sort(l,r:longint);
var
  i,j,x,y:longint;
begin
  x:=a[(l+r) div 2];
  i:=l;
  j:=r;
  repeat
    while a[i]<x do inc(i);
    while x<a[j] do dec(j);
    if i<=j then
    begin
      swap(a[i],a[j]);
      swap(b[i],b[j]);
      swap(c[i],c[j]);
      swap(p[i],p[j]);
      inc(i);
      dec(j);
    end;
  until i>j;
  if i<r then sort(i,r);
  if l<j then sort(l,j);
end;

procedure go(k:longint);
var
  i,now:longint;
begin
  case k of
    1:begin
      for i:=1 to n do
      a[i]:=x[1,i];
      for i:=1 to n do
      b[i]:=x[2,i];
      for i:=1 to n do
      begin
        c[i]:=x[3,i];
        p[i]:=i;
      end;
      sort(1,n);
      for i:=0 to 200000 do f[i]:=maxlongint;
      for i:=1 to n do
      begin
        now:=minnum(b[i]-1);
        if now<c[i] then
        begin
          v[p[i]]:=true;

        end;
        change(b[i],c[i]);
      end;
    end;

    2:begin
      for i:=1 to n do
      a[i]:=x[1,i];
      for i:=1 to n do
      b[i]:=x[3,i];
      for i:=1 to n do
      begin
        c[i]:=x[4,i];
        p[i]:=i;
      end;
      sort(1,n);
      for i:=0 to 200000 do f[i]:=maxlongint;
      for i:=1 to n do
      begin
        now:=minnum(b[i]-1);
        if now<c[i] then
        begin
          v[p[i]]:=true;
        end;
        change(b[i],c[i]);
      end;
    end;

    3:begin
      for i:=1 to n do
      a[i]:=x[2,i];
      for i:=1 to n do
      b[i]:=x[3,i];
      for i:=1 to n do
      begin
        c[i]:=x[4,i];
        p[i]:=i;
      end;
      sort(1,n);
      for i:=0 to 200000 do f[i]:=maxlongint;
      for i:=1 to n do
      begin
        now:=minnum(b[i]-1);
        if now<c[i] then
        begin
          v[p[i]]:=true;
        end;
        change(b[i],c[i]);
      end;
    end;

    4:begin
      for i:=1 to n do
      a[i]:=x[1,i];
      for i:=1 to n do
      b[i]:=x[2,i];
      for i:=1 to n do
      begin
        c[i]:=x[4,i];
        p[i]:=i;
      end;
      sort(1,n);
      for i:=0 to 200000 do f[i]:=maxlongint;
      for i:=1 to n do
      begin
        now:=minnum(b[i]-1);
        if now<c[i] then
        begin
          v[p[i]]:=true;
        end;
        change(b[i],c[i]);
      end;
    end;
  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(x[1,i],x[2,i],x[3,i],x[4,i]);
    p[i]:=i;
  end;
  go(1);
  go(2);
  go(3);
  go(4);
  for i:=1 to n do
  if v[i] then
  begin
    inc(top);
    q[top]:=i;
  end;
  writeln(top);
  for i:=1 to top do writeln(q[i]);
  close(input);
  close(output);
end.