记录编号 |
113746 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2011]瑞士轮 |
最终得分 |
100 |
用户昵称 |
传奇 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
1.172 s |
提交时间 |
2014-07-25 22:15:38 |
内存使用 |
34.50 MiB |
显示代码纯文本
program cojs625;
type
node=record
s,w:longint;
bh:longint;
end;
var
n,r,q,i,j,l:longint;
a,c,b:array[1..1000000] of node;
procedure qp(l,r:longint);
var
i,j:longint;
y,x:node;
begin
i:=l; j:=r;
x:=a[(l+r)div 2];
repeat
while (a[i].s>x.s)or((a[i].s=x.s)and(a[i].bh<x.bh)) do inc(i);
while (a[j].s<x.s)or((a[j].s=x.s)and(a[j].bh>x.bh)) do dec(j);
if i<=j then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
inc(i); dec(j);
end;
until i>j;
if j>l then qp(l,j);
if i<r then qp(i,r);
end;
procedure guibing(l,r:longint);
var
i,j,mid,p:longint;
begin
mid:=(l+r)div 2;
i:=l; j:=mid+1; p:=l;
while (i<=mid)and(j<=r) do
begin
if (b[i].s>b[j].s)or((b[i].s=b[j].s)and(b[i].bh<b[j].bh)) then
begin
c[p]:=b[i];
inc(p);
inc(i);
end
else
begin
c[p]:=b[j];
inc(p);
inc(j);
end;
end;
while i<=mid do
begin
c[p]:=b[i];
inc(p);
inc(i);
end;
while j<=r do
begin
c[p]:=b[j];
inc(j);
inc(p);
end;
for i:=l to r do
a[i]:=c[i];
end;
begin
assign(input,'swiss.in');
assign(output,'swiss.out');
reset(input);
rewrite(output);
readln(n,r,q);
for i:=1 to n*2 do
read(a[i].s);
for i:=1 to 2*n do
begin
read(a[i].w);
a[i].bh:=i;
end;
qp(1,2*n);
for i:=1 to r do
begin
j:=1;l:=0;
while j<2*n do
begin
if a[j].w>a[j+1].w then
begin
inc(a[j].s);
inc(l);
b[l]:=a[j];
b[n+l]:=a[j+1];
end
else
begin
inc(a[j+1].s);
inc(l);
b[l]:=a[j+1];
b[l+n]:=a[j];
end;
j:=j+2;
end;
guibing(1,2*n);
end;
writeln(a[q].bh);
close(input);
close(output);
end.