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

Re:下面的代码在POJ可以AC,可是在XOJ(链接在内)确实WA了。。。请牛人指教。

Posted by IceKingdom at 2009-01-24 10:45:58 on Problem 1273
In Reply To:下面的代码在POJ可以AC,可是在XOJ(链接在内)确实WA了。。。请牛人指教。 Posted by:yogafrank at 2008-10-15 23:57:07
咱俩刚好相反
我在POJ WA
在 厦门大学的OJ上面AC了。。。
Run ID User Problem Result Memory Time Language Code Length Judge Submit Time 
46079 winterlegend 1089 Accepted 80 K 8 MS Fpc 4896 B Apple 2009-01-24 10:44:45 
program         ditch ;
const   maxn    = 1000 ;
        maxm    = 100000 ;
type    arctype = record  d , w , next : longint ;  end ;
var     vertex  : array[1..maxn] of longint ;
        cur     : array[1..maxn] of longint ;
        h       : array[1..maxn] of longint ;
        e       : array[1..maxn] of longint ;
        q       : array[1..maxn] of longint ;
        arc     : array[1..maxm] of arctype ;
        level   : array[0..maxn shl 1,1..maxn] of longint ;
        len     : array[0..maxn shl 1] of longint ;
        n , m , tot : longint ;

procedure       addvertex( v0 : longint ) ;
begin
        inc( len[h[v0]] ) ;
        level[h[v0],len[h[v0]]] := v0 ;
end ;

procedure       addarc( x , y , w : longint ) ;
begin
        inc( tot ) ;
        arc[tot].d := y ;  arc[tot].w := w ;
        arc[tot].next := vertex[x] ;  vertex[x] := tot ;
end ;

procedure       bfs ;
var     head , tail , p : longint ;
begin
        fillchar( h , sizeof( h ) , $7f ) ;
        q[1] := n ;  h[n] := 0 ;
        head := 0 ;  tail := 1 ;
        repeat
         inc( head ) ;
         p := vertex[q[head]] ;
         while  ( p <> -1 )  do begin
          if  ( h[arc[p].d] = 2139062143 )
           then  begin
            h[arc[p].d] := h[q[head]]+1 ;
            inc( tail ) ;
            q[tail] := arc[p].d ;
            if  ( arc[p].d <> 1 )
             then  addvertex( arc[p].d ) ;
           end ;
          p := arc[p].next ;
         end ;
        until  head = tail ;
        h[1] := n ;
        for  p := 1 to n  do
         if  h[p] = 2139062143
          then  begin
           h[p] := 0 ;
           addvertex( p ) ;
          end ;
end ;

procedure       enter ;
var     x , y , w , i : longint ;
begin
        fillchar( vertex , sizeof( vertex ) , $ff ) ;
        tot := 0 ;

        readln( m , n ) ;
        for  i := 1 to m  do begin
         readln( x , y , w ) ;
         addarc( x , y , w ) ;
         addarc( y , x , 0 ) ;
        end ;
end ;

procedure       push( u , p : longint ) ;
var     x       : longint ;
begin
        if  ( e[u] < arc[p].w )
         then  x := e[u]
         else  x := arc[p].w ;
        inc( e[arc[p].d] , x ) ;
        dec( e[u] , x ) ;
        dec( arc[p].w , x ) ;
        if  ( p and 1 = 1 )
         then  inc( arc[p+1].w , x )
         else  inc( arc[p-1].w , x ) ;
end ;

procedure       relabel( u : longint ) ;
var     p , x   : longint ;
begin
        x := maxlongint ;
        p := vertex[u] ;
        while  ( p <> -1 )  do begin
         if  ( arc[p].w > 0 )  and  ( h[arc[p].d] < x )
          then  x := h[arc[p].d] ;
         p := arc[p].next ;
        end ;
        h[u] := 1+x ;
end ;

function        discharge( u : longint ) : boolean ;
begin
        discharge := false ;
        while  ( e[u] > 0 )  do
         if  ( cur[u] = -1 )
          then  begin
           relabel( u ) ;
           discharge := true ;
           cur[u] := vertex[u] ;
          end  else
         if  ( arc[cur[u]].w > 0 )  and  ( h[u] = h[arc[cur[u]].d]+1 )
          then  push( u , cur[u] )
          else  cur[u] := arc[cur[u]].next ;
end ;

procedure       blow( height : longint ) ;
var     i , j   : longint ;
begin
        for  i := height+1 to n  do begin
         for  j := 1 to len[i]  do begin
          h[level[i,j]] := n+1 ;
          addvertex( level[i,j] ) ;
         end ;
         len[i] := 0 ;
        end ;
end ;

procedure       initialize ;
var     p       : longint ;
begin
        fillchar( e , sizeof( e ) , 0 ) ;
        fillchar( h , sizeof( h ) , 0 ) ;
        bfs ;
        for  p := 1 to n  do
         cur[p] := vertex[p] ;

        p := vertex[1] ;
        while  ( p <> -1 )  do begin
         if  ( arc[p].w > 0 )
          then  begin
           inc( e[arc[p].d] , arc[p].w ) ;
           dec( e[1] , arc[p].w ) ;
           if  ( p and 1 = 1 )
            then  inc( arc[p+1].w , arc[p].w )
            else  inc( arc[p-1].w , arc[p].w ) ;
           arc[p].w := 0 ;
          end ;
         p := arc[p].next ;
        end ;
end ;

procedure       solve ;
var     now , k , i     : longint ;
begin
        initialize ;
        now := n ;
        while  ( now > 0 )  do begin
         dec( now ) ;
         for  i := len[now] downto 1  do
          if  ( discharge( level[now,i] ) )
           then  begin
            if  ( len[now] = 1 )
             then  blow( now ) ;
            k := h[level[now,i]] ;
            addvertex( level[now,i] ) ;
            level[now,i] := level[now,len[now]] ;
            dec( len[now] ) ;
            now := k ;
            break ;
           end ;
        end ;

        writeln(e[n]) ;
end ;

begin
        while  not seekeof  do begin
         enter ;
         solve ;
        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