题解

42 条题解

  • -2
    @ 2013-07-30 12:02:53

    var
      a,b,c:array[0..200000,1..3] of longint;
      i,n,r,q,j:longint;
      procedure kp(r,l:longint);
      var
      i,j,k1,k2:longint;
      begin
      i:=r;
      j:=l;
      k1:=a[(i+j) shr 1,1];
      k2:=a[(i+j) shr 1,3];
      while i<=j do begin
      while (a[i,1]>k1) or (a[i,1]=k1) and (a[i,3]<k2) do inc(i);
      while (a[j,1]<k1) or (a[j,1]=k1) and (a[j,3]>k2) do dec(j);
      if i<=j then begin
      a[0]:=a[i];
      a[i]:=a[j];
      a[j]:=a[0];
      inc(i);
      dec(j);
      end;
      end;
      if i<l then kp(i,l);
      if r<j then kp(r,j);
      end;
      procedure ys;
      var
      t,k,j:longint;
      begin
      i:=1;
      j:=1;
      t:=0;
      while (i<n) or (j<n) do begin
      if i>n then begin
      for k:=j to n do begin
      inc(t);
      a[t]:=c[k];
      end;
      exit;
      end;
      if j>n then begin
      for k:=i to n do begin
      inc(t);
      a[t]:=b[k];
      end;
      exit;
      end;
      if (b[i,1]<c[j,1]) or (b[i,1]=c[j,1]) and (b[i,3]>c[j,3]) then begin
      inc(t);
      a[t]:=c[j];
      inc(j);
      end else begin
      inc(t);
      a[t]:=b[i];
      inc(i);
      end;
      end;
      end;
      begin
      readln(n,r,q);
      for i:=1 to n*2 do begin
      read(a[i,1]);
      a[i,3]:=i;
      end;
      for i:=1 to 2*n do read(a[i,2]);
      kp(1,2*n);
      for j:=1 to r do begin
      for i:=1 to n do if a[i*2,2]>a[i*2-1,2] then begin
      inc(a[i*2,1]);
      b[i]:=a[i*2];
      c[i]:=a[i*2-1];
      end else begin
      inc(a[i*2-1,1]);
      b[i]:=a[i*2-1];
      c[i]:=a[i*2];
      end;
      ys;
      end;
      writeln(a[q,3]);
      end.

  • -3
    @ 2012-11-09 08:20:30

    目测是道很难的题目。。。。。。。

    点这里查看程序源码+详细题解

信息

ID
1771
难度
7
分类
模拟 | 数据结构 | 队列 点击显示
标签
递交数
3535
已通过
703
通过率
20%
被复制
18
上传者