锘??xml version="1.0" encoding="utf-8" standalone="yes"?>午夜精品视频,在线观看国产精品淫,亚洲宅男天堂在线观看无病毒http://m.shnenglu.com/tianlearn-language/archive/2010/12/11/136164.html鐢板叺鐢板叺Sat, 11 Dec 2010 08:48:00 GMThttp://m.shnenglu.com/tianlearn-language/archive/2010/12/11/136164.htmlhttp://m.shnenglu.com/tianlearn-language/comments/136164.htmlhttp://m.shnenglu.com/tianlearn-language/archive/2010/12/11/136164.html#Feedback0http://m.shnenglu.com/tianlearn-language/comments/commentRss/136164.htmlhttp://m.shnenglu.com/tianlearn-language/services/trackbacks/136164.html絎竴嬈″啓嬈″皬鐢熸垚鏍戯紝娌℃兂鍒?/div>
鎬濇兂灝辨槸錛氭眰涓嬈℃渶灝忕敓鎴愭爲錛岃褰曟墍鐢ㄥ埌鐨勮竟錛岀劧鍚庝笉鐢ㄦ墍鏈夌涓嬈$敤鍒扮殑杈瑰皾璇曟瀯鎴愭瀯鎴愭渶灝忕敓鎴愭爲銆?/div>
鐢↘ruskal鍏堟眰鏈灝忕敓鎴愭爲錛岀粨鏋滃嵆涓簃in錛屾妸鎵鐢ㄥ埌鐨勮竟璁板綍涓嬫潵錛堣繖閲屾槸璁板綍鐨勫搴旂殑涓嬭〃錛夛紝鐒跺悗鏋氫婦榪欎簺杈癸紝
姣忔鍘繪帀涓涓竟姹備竴嬈℃渶灝忕敓鎴愭爲錛岀粨鏋滀負tmin錛屽鏋滆兘澶熸垚鏈灝忕敓鎴愭爲騫朵笖tmin==min錛屽垯璇存槑鏈灝忕敓鎴愭爲涓嶅敮涓
#include<iostream> //poj 1679
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX = 101;
int n, m;

struct edge
{
    int x;
    int y;
    int len;
}E[MAX*MAX];

int fa[MAX];
int indexEdge[MAX];
int index;
bool cmp(const edge &a, const edge &b)
{
    return a.len < b.len;
}

int find(int x)
{
    if(fa[x] == x)return x;
    return fa[x] = find(fa[x]);
}

int Kruskal(int location)  //涓嶇敤location浣嶇疆鐨勮竟
{
    int ans = 0;
    int tx, ty;
    int cnt = 0;
    if (location == -1)index = 0;//location == -1 絎竴嬈℃眰鏈灝忕敓鎴愭爲錛宨ndexEdge[index]綰綍絎琲ndex鐢ㄥ埌鐨勮竟鐨勪笅鏍?/div>
    for(int k = 1; k <= n; k ++)fa[k] = k;

    for(int i = 0; i < m; i ++)
    {
        if(i == location)continue;
        tx = find(E[i].x);
        ty = find(E[i].y);
        if(tx != ty)
        {
            fa[tx] = ty;
            ans += E[i].len;
            cnt ++;
            if(location == -1)//絎竴嬈℃渶灝忕敓鎴愭爲鐨勬椂鍊欐妸location緗負-1
            {
                indexEdge[index] = i;
                index ++;
            }
            if(cnt == n - 1)break;
        }
    }

    if(cnt == n - 1)return ans;
    return -1;
}

int main()
{
    int t, i;
    scanf("%d",&t);
    while(t --)
    {
        memset(E, 0, sizeof E);
        memset(indexEdge, 0, sizeof indexEdge);

        scanf("%d %d",&n, &m);

        for(i = 0; i < m; i ++)
            scanf("%d %d %d",&E[i].x, & E[i].y , & E[i].len);

        sort(E, E + m, cmp);
        
        int min = Kruskal(-1);    
        int tmin = (1<<20), temp;
        //cout << index << endl;
        
        for(i = 0; i < index; i ++)
        {
            //cout <<i <<' '<< indexEdge[i]<< endl;
            temp = Kruskal(indexEdge[i]);
            if(temp != -1 && temp < tmin)
                tmin = temp;
        }
        
        if(tmin == min)
            printf("Not Unique!\n");
        else printf("%d\n",min);
    }
                           
    return 0;
}


鐢板叺 2010-12-11 16:48 鍙戣〃璇勮
]]>AOJ 236 Cow Picnic , poj 3256http://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125276.html鐢板叺鐢板叺Mon, 30 Aug 2010 07:49:00 GMThttp://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125276.htmlhttp://m.shnenglu.com/tianlearn-language/comments/125276.htmlhttp://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125276.html#Feedback0http://m.shnenglu.com/tianlearn-language/comments/commentRss/125276.htmlhttp://m.shnenglu.com/tianlearn-language/services/trackbacks/125276.html
Cow Picnic
Time Limit: 2000 ms   Memory Limit: 64 MB
Total Submission: 1   Accepted: 1
Description
The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N (1 ≤ N ≤ 1,000) pastures, conveniently numbered 1...N. The pastures are connected by M (1 ≤ M ≤ 10,000) one-way paths (no path connects a pasture to itself).

The cows want to gather in the same pasture for their picnic, but (because of the one-way paths) some cows may only be able to get to some pastures. Help the cows out by figuring out how many pastures are reachable by all cows, and hence are possible picnic locations.

Input
Line 1: Three space-separated integers, respectively: K, N, and M
Lines 2..K+1: Line i+1 contains a single integer (1..N) which is the number of the pasture in which cow i is grazing.
Lines K+2..M+K+1: Each line contains two space-separated integers, respectively A and B (both 1..N and A != B), representing a one-way path from pasture A to pasture B.

Output
Line 1: The single integer that is the number of pastures that are reachable by all cows via the one-way paths.

Sample Input
2 4 4
2
3
1 2
1 4
2 3
3 4
 

Sample Output
2[EOL][EOF]

Hint
The cows can meet in pastures 3 or 4.

Source
USACO 2006 December Silver 

浠庢瘡涓墰寮濮嬫眰涓嬈″崟婧愭渶鐭礬寰勶紝鍋囪璧風偣鏄疿錛屽鏋滀粠X鑳藉埌i (di[i]!=INF) 錛宑nt[i]++錛岀敤鏉ョ粺璁¤兘鍒拌揪 i 鐐圭殑鐗涚殑鏁伴噺銆?br>
緇撴灉灝辨槸婊¤凍cnt[i]==K鐨勬暟閲忥紝鍗砳鐐規墍鏈夌殑鐗涢兘鍙互鍒拌揪銆?br>
鐢╯pfa姹傦紝spfa鍦ㄨ繖閲屼笉鏄眰鏈孌佃礬寰勶紝鍙鍒頒簡灝辮錛屼笉闇瑕佹槸鏈鐭殑錛屽洜姝や細鏇村揩涓鐐廣?br>
#include<iostream>
#include
<time.h>
#include
<vector>
#include
<queue>
using namespace std;
const int MAX=1001,INF=0x0fffffff;
vector
<int> mp[MAX];
int d[MAX], cnt[MAX];
int K,N,M;
int stay[101];
void spfa(int x)
{
     
for(int i=1; i<=N; i++)
             d[i]
=INF;
     queue
<int>q;
     q.push(x);
     d[x]
=0;
     
while(q.size())
     {  
         
          
int u=q.front(); q.pop(); 
          
for(int i=0; i<mp[u].size(); i++)
          {
                  
if(d[mp[u][i]]==INF)
                  {
                       d[mp[u][i]]
=d[u]+1;
                       q.push(mp[u][i]);
                  }
          }
                    
     }
}

int main()
{
    cin
>>K>>N>>M;
    
    
for(int i=1; i<=K; i++)
            cin
>>stay[i];
    
    
for(int i=1,s,t; i<=M; i++)
            {
                     cin
>>s>>t;
                     mp[s].push_back(t);
            }
    
    
for(int i=1; i<=K; i++)
    {
       spfa(stay[i]);    
       
for(int i=1; i<=N; i++)
               
if(d[i]!=INF)cnt[i]++;   
    }
    
    
int ans=0;
    
    
for(int i=1; i<=N; i++)  
            
if(cnt[i]==K)ans++;
    
    cout
<<ans<<endl;        
    system(
"pause");
    
return 0;
}



鐢板叺 2010-08-30 15:49 鍙戣〃璇勮
]]>poj 1274 The Perfect Stall http://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125252.html鐢板叺鐢板叺Mon, 30 Aug 2010 02:09:00 GMThttp://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125252.htmlhttp://m.shnenglu.com/tianlearn-language/comments/125252.htmlhttp://m.shnenglu.com/tianlearn-language/archive/2010/08/30/125252.html#Feedback0http://m.shnenglu.com/tianlearn-language/comments/commentRss/125252.htmlhttp://m.shnenglu.com/tianlearn-language/services/trackbacks/125252.html
浜屽垎鍥劇殑鏈澶у尮閰嶏紝鍔犱竴涓簮鐐癸紝榪欎釜婧愮偣鍒板乏杈規墍鏈夐《鐐瑰姞涓鏉¤竟錛屾潈鍊間負1. 銆傚悓鐞嗭紝鍔犱竴涓粓鐐癸紝鎵鏈夊彸杈圭殑瀹氱偣鍒拌繖涓粓鐐規湁鏉¤竟錛屾潈鍊間負1. 榪欐牱浜屽垎鍥劇殑鏈澶у尮閰嶅氨杞崲鎴愪簡鏈澶ф祦闂銆?/span>

#include<iostream>
#include
<queue>
#include
<cstring>
using namespace std;
const int MAX=405;
int cap[MAX][MAX]={0};
int flow[MAX][MAX]={0};
int pre[MAX],m[MAX];
int N, M,S,T;
const int INF=10000000;

int bfs(int s)
{
    memset(m,
0,sizeof m);  
    memset(pre,
0,sizeof pre);
    queue
<int> q;
    q.push(s);
    m[s]
=INF;
    
while(!q.empty())
    {
            
int u=q.front(); q.pop();
            
for(int v=0; v<=N+M+1; v++)
                    
if(!m[v]&&cap[u][v]>flow[u][v])
                    {
                         pre[v]
=u;
                         m[v]
= m[u]>cap[u][v]-flow[u][v]?cap[u][v]-flow[u][v]:m[u];
                         q.push(v);
                    }
    }
    
   
if(m[T]==0)return 0;
   
   
for(int u=T; u!=S ; u=pre[u])
   {
           flow[pre[u]][u]
+=m[T];
           flow[u][pre[u]]
-=m[T];
   }
   
return m[T];
}

int main()
{
    
    
while(cin>>N>>M)
    {    memset(cap,
0,sizeof cap);
         memset(flow,
0,sizeof flow);
         
for(int i=1; i<=N; i++)
         {
            
int c,e;
            cin
>>c;
            
for(int j=1; j<=c; j++)
                   {
                         cin
>>e;
                         e
=e+N;
                         cap[i][e]
=1;
                   } 
         } 
         S
=0
         T
=N+M+1;
         
for(int i=1; i<=N; i++)
            cap[
0][i]=1;
            
         
for(int i=1; i<=M; i++)
            cap[N
+i][T]=1;
    
         
int ans=0;
         
while(1)
         {
            
int temp=bfs(S);
            
if(temp==0)break;
            
else ans+=temp;
         }
    
         cout
<<ans<<endl;
    }   
    system(
"pause");
    
return 0;
}


鐢板叺 2010-08-30 10:09 鍙戣〃璇勮
]]>
poj 1273 Drainage Ditcheshttp://m.shnenglu.com/tianlearn-language/archive/2010/08/25/124683.html鐢板叺鐢板叺Wed, 25 Aug 2010 07:30:00 GMThttp://m.shnenglu.com/tianlearn-language/archive/2010/08/25/124683.htmlhttp://m.shnenglu.com/tianlearn-language/comments/124683.htmlhttp://m.shnenglu.com/tianlearn-language/archive/2010/08/25/124683.html#Feedback0http://m.shnenglu.com/tianlearn-language/comments/commentRss/124683.htmlhttp://m.shnenglu.com/tianlearn-language/services/trackbacks/124683.html 
         璧よ8瑁哥殑鏈澶ф祦闂錛屼篃鏄垜鍐欑涓涓渶澶ф祦錛屾槸鍏ラ棬鐨勫ソ棰樸?br>
         鍙戠幇鐪嬩唬鐮佹湁鏃跺欐瘮鐪嬩功鏇村鏄撴噦錛岀湅鏈澶ф祦宸茬粡鐪嬩簡濂藉嚑澶╀功浜嗭紝閮芥槸鏅曚箮涔庣殑錛屽弬鑰冧簡涓涓嬪埆浜虹殑浠g爜錛屼技涔庢湁浜涗簡瑙d簡銆?br>
      Ford-Fulkerson鏂規硶鐨勫騫胯礬綆楁硶
      姣忔鐢╠fs瀵繪壘鍙騫胯礬寰勶紝璇ヨ礬寰勪笂鐨勬墍鏈夎竟鐨勫閲忓潎瑕佹槸姝f暟錛屽鏋滄壘鍒板氨鍙栬璺緞涓婃墍鏈夊閲忕殑鏈灝忓間綔涓哄鍔犵殑嫻併傚鏋滀笉瀛樺湪鍒欒鏄庡凡緇忔槸鏈澶ф祦錛岀粨鏉熴?br>
涓嬮潰榪欎袱涓▼搴忓湪hdu鏈夌偣灝忛棶棰橈紝絎笁涓槸鍦ㄤ袱涓狾J涓婇兘鍙互鐨勩?br>

#include<iostream>
using namespace std;
int map[250][250];
int pre[250];
bool visit[250];
int m,n,minflow;
const int INF=0x7fffffff/1000;

int dfs(int v)
{
    visit[v]
=true;
    
if(v==n)return 1;
    
for(int i=1; i<=n; i++)
            
if(map[v][i]>0&&!visit[i])
              { 
                  pre[i]
=v;
                  minflow
=minflow>map[v][i]?map[v][i]:minflow;
                  
if(dfs(i))return true;
              }
    
return 0;
}

int maxflow()
{
    
int maxf=0;
    
while(1)
    {
           memset(pre,
0,sizeof pre);
           minflow
=INF;
           memset(visit,
0,sizeof visit);
           pre[
1]=-1;
           
if(dfs(1))
           {
                    
                     
int inc=minflow;
                     
int t=n;
                     
while(pre[t]!=-1)
                     {
                          
int qq=pre[t];
                          map[qq][t]
-=inc;
                          map[t][qq]
+=inc;
                          t
=qq;
                     }
                     maxf
+=inc;
           }
           
else break;
    }
    
return maxf;
}

int main()
{
    
while(cin>>m>>n)
    {
       
int s,t,c;
       memset(map,
0,sizeof map);
       
while(m--)
       {
                cin
>>s>>t>>c;
                map[s][t]
+=c; 
       }               
       cout
<<maxflow()<<endl;
    }
    
   system(
"pause");
   
return 0;   
}

鐢˙FS鐨凟dmonds-Karp綆楁硶
#include<iostream>
#include
<queue>
using namespace std;
int map[250][250];
int pre[250];
bool visit[250];
int m,n,minflow;
const int INF=0x7fffffff/1000;

int bfs(int s)
{
    queue
<int> Q;
    Q.push(s);
    visit[s]
=true;
    
while(Q.size())
    {
         
int v=Q.front(); Q.pop();
         
if(v==n)return true ; 
         
for(int i=1; i<=n; i++)
                 
if(!visit[i]&&map[v][i]>0&&!visit[n])
                 {  
                     pre[i]
=v;
                     visit[i]
=true;
                     minflow
=minflow>map[v][i]?map[v][i]:minflow;
                     Q.push(i);
                 }
                   
    }
    
return false;
}

int maxflow()
{
    
int maxf=0;
    
while(1)
    {
           memset(pre,
0,sizeof pre);
           minflow
=INF;
           memset(visit,
0,sizeof visit);
           pre[
1]=-1;
           
if(bfs(1))
           {
                     
int inc=minflow;
                     
int t=n;
                     
while(pre[t]!=-1)
                     {
                          
int qq=pre[t];
                          map[qq][t]
-=inc;
                          map[t][qq]
+=inc;
                          t
=qq;
                     }
                     maxf
+=inc;
           }
           
else break;
    }
    
return maxf;
}

int main()
{
    
while(cin>>m>>n)
    {
       
int s,t,c;
       memset(map,
0,sizeof map);
       
while(m--)
       {
                cin
>>s>>t>>c;
                map[s][t]
+=c; 
       }               
       cout
<<maxflow()<<endl;
    }
    
   system(
"pause");
   
return 0;   
}

闂鎴栬灝卞嚭鐜板湪鍙栨渶灝忓肩殑闂涓婏紝涓嶈繃鎴戣涓哄墠涓ょ姣忔鍙栫殑鍙兘涓嶆槸鏈灝忕殑錛屼絾搴旇鏄病閿欑殑銆?br>鏈澶氬dfs鎴朾fs鍑犳銆?br>
#include<iostream>
#include
<string.h>
using namespace std;
int map[250][250];
int pre[250],q[250];
bool visit[250];
int m,n;
const int INF=0x7fffffff;

bool dfs(int v)
{
    visit[v]
=true;
    
if(v==n)return true;
    
for(int i=1; i<=n; i++)
            
if(map[v][i]>0&&!visit[i])
              { 
                  pre[i]
=v;
                  q[i]
=q[v]>map[v][i]?map[v][i]:q[v];
                  
if(dfs(i))return true;
              }
    
return 0;
}

int maxflow()
{
    
int maxf=0;
    
while(1)
    {
           memset(pre,
0,sizeof pre);
           memset(q,
0,sizeof q);
           
//for(int i=1; i<=n; i++)
                   q[1]=INF;
           memset(visit,
0,sizeof visit);
           pre[
1]=-1;
           
if(dfs(1))
           {
                    
                     
int inc=q[n];
                     
int t=n;
                     
while(pre[t]!=-1)
                     {
                          
int qq=pre[t];
                          map[qq][t]
-=inc;
                          map[t][qq]
+=inc;
                          t
=qq;
                     }
                     maxf
+=inc;
           }
           
else break;
    }
    
return maxf;
}

int main()
{
    
while(cin>>m>>n)
    {
       
int s,t,c;
       memset(map,
0,sizeof map);
       
while(m--)
       {
                cin
>>s>>t>>c;
                map[s][t]
+=c; 
       }               
       cout
<<maxflow()<<endl;
    }
    
   system(
"pause");
   
return 0;   
}


鐢板叺 2010-08-25 15:30 鍙戣〃璇勮
]]>
poj 3268 Silver Cow Party 銆愪袱嬈ijstra銆?/title><link>http://m.shnenglu.com/tianlearn-language/archive/2010/08/19/123925.html</link><dc:creator>鐢板叺</dc:creator><author>鐢板叺</author><pubDate>Thu, 19 Aug 2010 01:38:00 GMT</pubDate><guid>http://m.shnenglu.com/tianlearn-language/archive/2010/08/19/123925.html</guid><wfw:comment>http://m.shnenglu.com/tianlearn-language/comments/123925.html</wfw:comment><comments>http://m.shnenglu.com/tianlearn-language/archive/2010/08/19/123925.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/tianlearn-language/comments/commentRss/123925.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/tianlearn-language/services/trackbacks/123925.html</trackback:ping><description><![CDATA[棰樻剰錛?br>             灝辨槸浠庡悇鐐瑰埌X鐨勬渶鐭窛紱誨強浠嶺鍒板悇鐐圭殑鏈鐭窛紱誨拰鐨勬渶澶у箋?br><br>絎竴鍒╃敤dijstra姹傚嚭浠嶺鍒板悇鐐圭殑鏈鐭窛紱匯?br><br>鐒跺悗鎵鏈夌殑杈瑰弽鍚戯紝鍐嶈繘琛屼竴嬈ijstra姹俋鍒板悇鐐圭殑鏈鐭礬寰勩?br><br>絎簩嬈℃眰鍑虹殑鏈鐭礬寰勪篃灝辨槸鍚勭偣鍒癤鐨勬渶鐭礬寰勶紝鍥犱負杈瑰凡緇忓弽鍚戯紝瀵逛簬絎簩嬈′粠X鍒板悇鐐圭殑鏈鐭礬寰勬鏄?br>鍘熷浘浠庡悇鐐瑰埌X鐨勬渶鐭礬寰勩?br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">queue</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br></span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> INF</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0x7fffffff</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> map[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">};<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> d[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">},N,M,X;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> dd[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">};<br></span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000"> f[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> dijstra()<br>{<br>     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>             d[i]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">INF;<br>     d[X]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>     memset(f,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> f);<br>     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>     {<br>             </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> min</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">INF,u</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>             </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>                     </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(d[j]</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">min</span><span style="COLOR: #000000">&&!</span><span style="COLOR: #000000">f[j])<br>                     {<br>                                 min</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">d[j];<br>                                 u</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">j;<br>                     }<br>             f[u]</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br>             </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>             {<br>                     </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(d[u]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">map[u][j]</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">d[j])<br>                        d[j]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">d[u]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">map[u][j];<br>             }<br>     }<br>     <br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> traverse()<br>{<br>     </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> temp;<br>     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">i; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>     {<br>             temp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> map[i][j];<br>             map[i][j]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">map[j][i];<br>             map[j][i]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">temp;<br>     }<br>}<br><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br><br>    cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">N</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">M</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">X;<br>    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            map[i][j]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">INF;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,s,t,value; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">M; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>          cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">t</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">value;<br>          map[s][t]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">value;<br>    }<br>    <br>    dijstra();<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>             dd[i]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">d[i]; <br>            <br>    traverse();<br>    dijstra();<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> max</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">N; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(d[i]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">dd[i]</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">max)max</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">d[i]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">dd[i];<br>    <br>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">max</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>    <br>    system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}<br></span></div> <img src ="http://m.shnenglu.com/tianlearn-language/aggbug/123925.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/tianlearn-language/" target="_blank">鐢板叺</a> 2010-08-19 09:38 <a href="http://m.shnenglu.com/tianlearn-language/archive/2010/08/19/123925.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>AOJ--The Max Weight--Floyd Folyd綆楁硶鍙樺艦錛屾妸姹傛渶鐭礬寰勭殑鍜屾敼涓烘眰鏈澶ц澆閲嶉噺鐨勯棶棰?/title><link>http://m.shnenglu.com/tianlearn-language/archive/2010/05/29/116704.html</link><dc:creator>鐢板叺</dc:creator><author>鐢板叺</author><pubDate>Sat, 29 May 2010 14:03:00 GMT</pubDate><guid>http://m.shnenglu.com/tianlearn-language/archive/2010/05/29/116704.html</guid><wfw:comment>http://m.shnenglu.com/tianlearn-language/comments/116704.html</wfw:comment><comments>http://m.shnenglu.com/tianlearn-language/archive/2010/05/29/116704.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/tianlearn-language/comments/commentRss/116704.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/tianlearn-language/services/trackbacks/116704.html</trackback:ping><description><![CDATA[<div id="hvzpftn" class=BigTitle align=center>The Max Weight</div> <div id="hvzpftn" class=Limits align=center>Time Limit: 1000 ms   Memory Limit: 64 MB<br>Total Submission: 36   Accepted: 4 </div> <div id="hvzpftn" class=Special align=center></div> <div id="hvzpftn" class=ProblemTitle>Description</div> <div id="hvzpftn" class=ProblemContent>There a lot of bridges connect different positions in Venice,but they can't carry too much weigh,so each of them has a limit which can be described as an interger.A man wants to carry some goods from positon 1 to n.Help him find how much can he carry.</div> <br> <div id="hvzpftn" class=ProblemTitle>Input</div> <div id="hvzpftn" class=ProblemContent>There are T cases.<br>For each case,the number of positions ( 1 < = n < = 100) and number m of bridges are exhibited on the first line.The following m lines contain triples of integers specifying start and end positions of the bridge and the maximum allowed weight, which is positive and not larger than 1000000. There will be at most one bridge between each pair of crossings.</div> <br> <div id="hvzpftn" class=ProblemTitle>Output</div> <div id="hvzpftn" class=ProblemContent>The output for every scenario begins with a line containing "Case #i:", where i is the number of the scenario starting at 1. Then print a single line containing the maximum allowed weight that the man can transport. Terminate the output for the scenario with a blank line.</div> <br> <div id="hvzpftn" class=ProblemTitle>Sampel Input</div> <div id="hvzpftn" class=IO>1<br>3 3<br>1 2 3<br>1 3 4<br>2 3 5 </div> <br> <div id="hvzpftn" class=ProblemTitle>Sample Output</div> <div id="hvzpftn" class=IO>Case #1:<abbr>[EOL]</abbr><br>4<abbr>[EOF]</abbr></div> <br>棰樻剰錛?br>n涓偣錛屾湁浜涚偣闂存湁妗ワ紝妗ヤ笂鏈夋渶澶ф壙閲嶉噺錛岄棶浣犱粠1鍒皀鍙互鏈澶ф惡甯︾殑鐗╁搧鐨勯噸閲忋?br>棰樿В錛?nbsp;<br> Folyd綆楁硶鍙樺艦錛屾妸姹傛渶鐭礬寰勭殑鍜屾敼涓烘眰鏈澶ц澆閲嶉噺鐨勯棶棰橈紝鍏抽敭鏄痙is[i][j]=dis[i][j]>dis[i][k]+dis[k][j]?dis[i][j]>dis[i][k]+dis[k][j]?:dis[i][j];鎹㈡垚dis[i][j]<span style="COLOR: #000000">=</span><span style="COLOR: #000000">max(dis[i][j],min(dis[i][k],dis[k][j]));</span><br> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-FAMILY: courier new; FONT-SIZE: 14pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008080"> 1</span><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cmath</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> dis[</span><span style="COLOR: #000000">105</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">105</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008080"> </span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Floyd(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n)<br></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img id=Codehighlighter1_151_358_Open_Image onclick="this.style.display='none'; Codehighlighter1_151_358_Open_Text.style.display='none'; Codehighlighter1_151_358_Closed_Image.style.display='inline'; Codehighlighter1_151_358_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_151_358_Closed_Image onclick="this.style.display='none'; Codehighlighter1_151_358_Closed_Text.style.display='none'; Codehighlighter1_151_358_Open_Image.style.display='inline'; Codehighlighter1_151_358_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_151_358_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_151_358_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; k</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">n; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">n; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">     </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">n; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img id=Codehighlighter1_245_356_Open_Image onclick="this.style.display='none'; Codehighlighter1_245_356_Open_Text.style.display='none'; Codehighlighter1_245_356_Closed_Image.style.display='inline'; Codehighlighter1_245_356_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_245_356_Closed_Image onclick="this.style.display='none'; Codehighlighter1_245_356_Closed_Text.style.display='none'; Codehighlighter1_245_356_Open_Image.style.display='inline'; Codehighlighter1_245_356_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">     </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_245_356_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_245_356_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">       </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">k</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">j</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">k</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">dis[i][k]</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">dis[k][j])<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         dis[i][j]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">max(dis[i][j],min(dis[i][k],dis[k][j]));<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">     }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img id=Codehighlighter1_372_710_Open_Image onclick="this.style.display='none'; Codehighlighter1_372_710_Open_Text.style.display='none'; Codehighlighter1_372_710_Closed_Image.style.display='inline'; Codehighlighter1_372_710_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_372_710_Closed_Image onclick="this.style.display='none'; Codehighlighter1_372_710_Closed_Text.style.display='none'; Codehighlighter1_372_710_Open_Image.style.display='inline'; Codehighlighter1_372_710_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_372_710_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_372_710_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> t,i,j,m,n;<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">t;<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; k</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">t; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img id=Codehighlighter1_437_694_Open_Image onclick="this.style.display='none'; Codehighlighter1_437_694_Open_Text.style.display='none'; Codehighlighter1_437_694_Closed_Image.style.display='inline'; Codehighlighter1_437_694_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_437_694_Closed_Image onclick="this.style.display='none'; Codehighlighter1_437_694_Closed_Text.style.display='none'; Codehighlighter1_437_694_Open_Image.style.display='inline'; Codehighlighter1_437_694_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_437_694_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_437_694_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">m;<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      memset(dis,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> (dis));<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> s,e,w; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">m; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img id=Codehighlighter1_539_600_Open_Image onclick="this.style.display='none'; Codehighlighter1_539_600_Open_Text.style.display='none'; Codehighlighter1_539_600_Closed_Image.style.display='inline'; Codehighlighter1_539_600_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_539_600_Closed_Image onclick="this.style.display='none'; Codehighlighter1_539_600_Closed_Text.style.display='none'; Codehighlighter1_539_600_Open_Image.style.display='inline'; Codehighlighter1_539_600_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">      </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_539_600_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_539_600_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">e</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">w;<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        dis[s][e]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">dis[e][s]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">w;<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">      }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      <br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      Floyd(n);<br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">      <br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">     cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Case #</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">k</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">dis[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][n]</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <img src ="http://m.shnenglu.com/tianlearn-language/aggbug/116704.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/tianlearn-language/" target="_blank">鐢板叺</a> 2010-05-29 22:03 <a href="http://m.shnenglu.com/tianlearn-language/archive/2010/05/29/116704.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>USACO--AOJ Bessie Come Home --Floyd綆楁硶http://m.shnenglu.com/tianlearn-language/archive/2010/05/23/116182.html鐢板叺鐢板叺Sun, 23 May 2010 12:03:00 GMThttp://m.shnenglu.com/tianlearn-language/archive/2010/05/23/116182.htmlhttp://m.shnenglu.com/tianlearn-language/comments/116182.htmlhttp://m.shnenglu.com/tianlearn-language/archive/2010/05/23/116182.html#Feedback1http://m.shnenglu.com/tianlearn-language/comments/commentRss/116182.htmlhttp://m.shnenglu.com/tianlearn-language/services/trackbacks/116182.htmlBessie Come Home

Time Limit:JAVA/Others2000/1000MS  Memory Limit:JAVA/Others131072/65536KB
Total Submit:6 Accepted:2

Description

It's dinner time, and the cows are out in their separate pastures. Farmer John rings the bell so they will start walking to the barn. Your job is to figure out which one cow gets to the barn first (the supplied test data will always have exactly one fastest cow).

Between milkings, each cow is located in her own pasture, though some pastures have no cows in them. Each pasture is connected by a path to one or more other pastures (potentially including itself). Sometimes, two (potentially self-same) pastures are connected by more than one path. One or more of the pastures has a path to the barn. Thus, all cows have a path to the barn and they always know the shortest path. Of course, cows can go either direction on a path and they all walk at the same speed.

The pastures are labeled `a'..`z' and `A'..`Y'. One cow is in each pasture labeled with a capital letter. No cow is in a pasture labeled with a lower case letter. The barn's label is `Z'; no cows are in the barn, though.

Input

Line 1: Integer P (1 <= P <= 10000) the number of paths that interconnect the pastures (and the barn)
Line 2..P+1: Space separated, two letters and an integer: the names of the interconnected pastures/barn and the distance between them (1 <= distance <= 1000)

Output

A single line containing two items: the capital letter name of the pasture of the cow that arrives first back at the barn, the length of the path followed by that cow.

Sample Input

5
A d 6
B d 3
C e 9
d Z 8
e Z 3

Sample Output

B 11

 1Floyd 綆楁硶錛?a >http://icpc.ahu.edu.cn:8080/AOJ/   鍋氱殑絎竴涓浘璁洪
 2鍥劇殑鏈鐭礬寰勯棶棰橈紝鍒?#8216;Z’鐨勬渶鐭礬寰勶紱
 3Floyd綆楁硶澶ф鐭ラ亾鎬庝箞鐢ㄤ簡 錛屽ソ鍍忔槸鍔ㄦ佽鍒掑疄鐜扮殑錛屼笉鐭ラ亾涓轟粈涔堣繖鏍鋒槸瀵圭殑
 4O錛圢^3錛夋眰瑙f渶鐭礬寰勯棶棰橈紝鏁版嵁鑼冨洿瓚呰繃400鍙兘灝卞嵄闄╀簡
 5#include<iostream>
 6#include<string.h>
 7using namespace std;
 8int dis[53][53];
 9const int INF=10000000;
10void Floyd(int n)
11{
12     for(int k=1; k<=n; k++)
13     for(int i=1; i<=n; i++)
14     for(int j=1; j<=n; j++)
15      if(i!=k&&k!=j&&i!=j&&dis[i][k]+dis[k][j]<dis[i][j])
16      dis[i][j]=dis[i][k]+dis[k][j];
17
18}

19
20
21int main()
22{
23    int p,i,j,k,d,n1,n2; 
24    cin>>p;
25    memset(dis,0,sizeof (dis));
26    for(i=1; i<=52; i++)
27    for(j=1; j<=52; j++)
28    dis[i][j]=INF;
29     
30    for(i=1; i<=p; i++)
31    {
32       char v1,v2;
33       cin>>v1>>v2>>d;      
34       if(v1==v2)continue;
35       n1=(v1>='a'?v1-'a'+1:v1-'A'+26+1);
36       n2=(v2>='a'?v2-'a'+1:v2-'A'+26+1);
37       if(d<dis[n1][n2])dis[n1][n2]=dis[n2][n1]=d;
38    }

39    
40    Floyd(52);
41    
42    int min=INF+100;
43    char c;
44    for(i=27; i<=51; i++//澶у啓瀛楁瘝鍒癦 
45    {
46       if(dis[i][52]<min){min=dis[i][52];c=i; }
47    }

48    cout<<char(c-27+'A')<<' '<<min<<endl;
49    //system("pause");
50    return 0;
51}

52



鐢板叺 2010-05-23 20:03 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              亚洲欧洲精品一区二区三区| 午夜精品免费| 亚洲欧美高清| 欧美韩日一区二区| 亚洲人成网站色ww在线| 在线看视频不卡| 久久免费精品视频| 欧美69wwwcom| 亚洲欧洲三级电影| 欧美日韩网站| 久久久久久久欧美精品| 校园春色综合网| 国产欧美精品久久| 宅男66日本亚洲欧美视频| 久久久久国产成人精品亚洲午夜| 欧美电影免费网站| 久久不射2019中文字幕| 欧美老女人xx| 欧美日韩理论| 亚洲综合精品一区二区| 一本一本久久a久久精品综合麻豆 一本一本久久a久久精品牛牛影视 | 国内精品久久久久伊人av| 亚洲最新在线| 亚洲承认在线| 久久国产精彩视频| 亚洲欧美久久久| 亚洲免费成人av电影| 国产精品超碰97尤物18| 欧美国产视频日韩| 欧美一区2区三区4区公司二百| 香蕉久久夜色精品国产使用方法| 夜夜嗨av一区二区三区四区| 国产主播一区二区三区| 国产在线精品成人一区二区三区| 韩日精品视频| 国产日韩视频| 99精品国产热久久91蜜凸| 一区二区三区在线观看视频| 亚洲精品在线观看视频| 久久综合久久久久88| 亚洲女爱视频在线| 欧美激情按摩| 亚洲欧美综合| 久久精品人人爽| 欧美一区三区三区高中清蜜桃| 亚洲日本成人网| 欧美国产日韩精品免费观看| 欧美风情在线| 欧美激情一区二区三区四区 | 久久国产精品99精品国产| 尤物99国产成人精品视频| 夜夜嗨av一区二区三区网页 | 午夜久久99| 欧美一区二区在线| 在线视频一区二区| 亚洲观看高清完整版在线观看| 在线成人h网| 免费观看日韩| 欧美.www| 久久久久se| 国产乱码精品1区2区3区| 在线视频欧美一区| 美女脱光内衣内裤视频久久影院 | 免费在线欧美视频| 亚洲国产精品久久久久秋霞影院| 一区二区三区免费看| 欧美成人免费小视频| 亚洲国产精品va| 国产欧美日韩亚州综合| 亚洲福利一区| 久久av一区二区三区漫画| 欧美在线一区二区| 国产精品九九| 免费高清在线一区| 亚洲欧美成人一区二区三区| 性欧美长视频| 好看的日韩av电影| 亚洲国产专区校园欧美| 在线视频日韩精品| 国产精品你懂的在线欣赏| 午夜精品久久久久| 久久视频国产精品免费视频在线 | 国产精品啊啊啊| 91久久一区二区| 99riav国产精品| 国产精品综合不卡av| 另类天堂av| 欧美日本一区| 久久精品一区二区| 欧美激情一区二区三区蜜桃视频| 亚洲欧洲一二三| 亚洲一区二区三区欧美| 亚洲视频自拍偷拍| 久久人人爽人人爽| 亚洲国内欧美| 国产精品白丝av嫩草影院| 久久综合久久久久88| 国产九色精品成人porny| 亚洲国产婷婷香蕉久久久久久99 | 午夜精品福利在线| 国产色综合久久| 亚洲电影免费在线| 久久一区中文字幕| 亚洲一区制服诱惑| 欧美电影免费观看| 久久视频在线看| 欧美亚州韩日在线看免费版国语版| 欧美a级片网| 夜夜躁日日躁狠狠久久88av| 欧美精品一区二区三区高清aⅴ| 蜜桃精品久久久久久久免费影院| 国产精品国产三级国产aⅴ无密码| 亚洲欧美一区二区在线观看| 性久久久久久| 国内精品视频在线播放| 久久综合久久久| 男女av一区三区二区色多| 伊人久久大香线蕉av超碰演员| 久久免费精品视频| 亚洲另类自拍| 亚洲欧美视频一区| 欧美福利专区| 日韩午夜在线观看视频| 亚洲一区二区免费| 国产精品嫩草影院一区二区| 久久精品一区二区三区中文字幕| 久久精品日韩| 亚洲午夜激情| 亚洲韩日在线| 国产欧美日韩麻豆91| 欧美激情一区二区三区 | 亚洲第一毛片| 国产精品久久婷婷六月丁香| 亚洲国产成人久久综合一区| 99精品国产福利在线观看免费| 国外成人在线视频网站| 欧美婷婷六月丁香综合色| 国产美女诱惑一区二区| 午夜日韩视频| 洋洋av久久久久久久一区| 亚洲精品美女在线观看播放| 亚洲深夜激情| aa级大片欧美| 亚洲一级片在线观看| 欧美性理论片在线观看片免费| 欧美精品不卡| 久久青草福利网站| 欧美在线一二三| 91久久国产精品91久久性色| 欧美黑人多人双交| 亚洲第一色在线| 蜜臀va亚洲va欧美va天堂| 亚洲电影av| 欧美激情精品久久久久久黑人| 麻豆91精品| 亚洲尤物视频在线| 欧美3dxxxxhd| 欧美日韩精品在线播放| 国产一区二区三区的电影| 国产一区二区三区网站| 亚洲美女啪啪| 亚洲精品视频在线观看免费| 欧美一级午夜免费电影| 亚洲成在线观看| 久久躁日日躁aaaaxxxx| 欧美成人官网二区| 亚洲美女91| 欧美午夜精品久久久久免费视| 亚洲大片av| 欧美激情视频网站| 欧美一区二区三区成人| 欧美高清成人| 欧美视频二区36p| 国产精品综合| 久久精品91久久香蕉加勒比| 欧美大片国产精品| 蜜臀91精品一区二区三区| 美女精品在线观看| 亚洲成色777777女色窝| 午夜久久久久| 欧美精品一区二区三区久久久竹菊 | 亚洲视频自拍偷拍| 久久婷婷激情| 国产一区二区| 亚洲日本va午夜在线电影| 欧美日本一区二区高清播放视频| 国产精品欧美一区喷水| 在线综合亚洲欧美在线视频| 亚洲欧美一区二区在线观看| 麻豆精品视频在线观看视频| 亚洲视频在线观看免费| 亚洲女女女同性video| 国产精品盗摄久久久| 欧美伊人久久久久久久久影院| 性色一区二区| 国产日韩欧美不卡在线| 亚洲国产精品va在线看黑人| 麻豆成人综合网| 亚洲三级免费| 午夜精品久久久久久久99热浪潮|