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 hell_angel at 2011-05-15 09:47:55 on Problem 2060
type
  re=record
    x1, y1, x2, y2: longint;
    st, ed: longint;
  end;
var
  i, j, k, n, m, ii: longint;
  ans: longint;
  s: string;
  a: array[0..501] of re;
  tg: array[0..1001,0..1001] of longint;
  g: array[0..1001,0..1001] of boolean;
  rec: array[0..1001] of longint;
  b: array[0..1001] of boolean;
  
procedure work2(s: string;i: longint);
var
  j, k: longint;
  tmp, tt, ttt: longint;
  ss: string;
  
begin
  tmp := pos(':',s);
  ss := copy(s,1,tmp-1);
  while (ss[1]='0') and (ss<>'') do delete(ss,1,1);
  if ss='' then tt := 0 else val(ss,tt);
  tt := tt*60;
  delete(s,1,tmp);
  while (s[1]='0') and (s<>'') do delete(s,1,1);
  if s='' then ttt := 0 else val(s,ttt);
  a[i].st := tt+ttt;
end;
  
procedure work(s: string;i: longint);
var
  j, k: longint;
  tmp: longint;
  ss: string;
  
begin
  tmp := pos(' ',s);
  ss := copy(s,1,tmp-1);
  work2(ss,i);
  delete(s,1,tmp);
  tmp := pos(' ',s);
  ss := copy(s,1,tmp-1);
  val(ss,a[i].x1);
  delete(s,1,tmp);
  tmp := pos(' ',s);
  ss := copy(s,1,tmp-1);
  val(ss,a[i].y1);
  delete(s,1,tmp);
  tmp := pos(' ',s);
  ss := copy(s,1,tmp-1);
  val(ss,a[i].x2);
  delete(s,1,tmp);
  val(s,a[i].y2);
  a[i].ed := a[i].st+abs(a[i].x1-a[i].x2)+abs(a[i].y1-a[i].y2);
 // writeln(a[i].st,' ',a[i].ed,' ',i);
end;

function yes(i,j: longint): boolean;
var
  k: longint;
begin
  if i=j then exit(false);
  if a[i].ed>=a[j].st then exit(false);
  if a[i].ed<a[j].st then begin
    k := abs(a[i].x2-a[j].x1)+abs(a[i].y2-a[j].y1);
    if k<=a[j].st-a[i].ed then exit(true);
    exit(false);
  end;
end;

procedure buildgragh;
var
  i, j, k: longint;
begin
  fillchar(tg,sizeof(tg),0);
  for i := 1 to n do
    for j := 1 to n do if (yes(i,j)) then begin
      inc(tg[i,0]);
      tg[i,tg[i,0]] := j;
    end;
end;

function dfs(x: longint): boolean;
var
  i: longint;
begin
  for i := n+1 to 2*n do if (not b[i]) and (g[x,i]) then begin
    b[i] := true;
    if (rec[i]=0) or (dfs(rec[i])) then begin
      rec[i] := x;
      exit(true);
    end;
  end;
  exit(false);
end;

procedure print;
var
  i, j, k: longint;
begin
  for i := 1 to n do begin
    write(tg[i,0],':');
    for j := 1 to tg[i,0] do write(tg[i,j],' ');
    writeln;
  end;
end;
  
begin
  assign(input,'d:\01.in');
  reset(input);
  assign(output,'d:\01.out');
  rewrite(output);
  readln(m);
  for ii := 1 to m do begin
    readln(n);
    for i := 1 to n do begin
      readln(s);
      work(s,i);
    end;
    buildgragh;
   // print;//****
    fillchar(g,sizeof(g),false);
    fillchar(rec,sizeof(rec),0);
    for i := 1 to n do
      for j := 1 to tg[i,0] do begin
        g[i,tg[i,j]+n] := true;
        g[tg[i,j]+n,i] := true;
      end;
    ans := 0;
    for i := 1 to n do begin
      fillchar(b,sizeof(b),false);
      if dfs(i) then inc(ans);
    end;
    writeln(n-ans);
   // writeln;
  end;
  close(input);
  close(output);
end.

不知道为什么一直是WA 到底哪儿错了啊啊啊啊 帮我找找错好吗

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