Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么wa啊啊啊 求助

Posted by shadowac at 2011-08-04 21:53:09 on Problem 3067
var a:array[0..2000] of int64;
    x,y:array[0..1000010] of int64;
    i,n,t,tmp:longint;
    ans:int64;
function ask(k:longint):longint;
begin
  ask:=0;
  while k<>0 do
  begin
    inc(ask,a[k]);
    k:=k-k and (-k);
  end;
end;
procedure add(k:longint);
begin
  while k<=2000 do
  begin
    inc(a[k]);
    k:=k+k and (-k);
  end;
end;
procedure qsort(s,t:longint);
var i,j:longint;
begin
  i:=s; j:=t; x[0]:=x[(i+j) shr 1]; x[(i+j) shr 1]:=x[i];
  y[0]:=y[(i+j) shr 1]; y[(i+j) shr 1]:=y[i];
  while i<j do
  begin
    while (i<j) and ((x[j]>x[0]) or ((x[j]=x[0]) and (y[j]>y[0]))) do dec(j);
    if i<j then begin y[i]:=y[j]; x[i]:=x[j]; end;
    while (i<j) and ((x[i]<x[0]) or ((x[i]=x[0]) and (y[i]<y[0]))) do inc(i);
    if i<j then begin x[j]:=x[i]; y[j]:=y[i]; end;
  end;
  x[i]:=x[0]; y[i]:=y[0]; inc(i); dec(j);
  if i<t then qsort(i,t);
  if s<j then qsort(s,j);
end;
begin
  readln(t);
  tmp:=0;
  while tmp<t do
  begin
    inc(tmp);
    readln(n,n,n);
    for i:=1 to n do readln(x[i],y[i]);
    qsort(1,n);
    ans:=0;
    for i:=1 to n do begin inc(ans,i-ask(y[i])-1); add(y[i]); end;
    writeln('Test case ',tmp,': ',ans);
  end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator