• <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>

            巢穴

            about:blank

            P1860

            Bellman-Ford
            看題看了半天..
            #include <iostream>
            #include 
            <vector>
            #include 
            <fstream>
            using namespace std;

            //ifstream fin("t1860.in");
            struct node
            {
             
            int u,v;
             
            double r,c;
            }
            ;
            vector
            <node> edge_vec;
            int n,m,s;
            int f;
            #define eps 1e-8
            double v;
            double dist[200];
            void relax(int x,int y,double r,double c)
            {
                 
            if (dist[y]+eps<(dist[x]-c)*r)
                    
            {f=1;dist[y]=(dist[x]-c)*r;}
            }

            bool bellman()
            {
                 
            for (int i=1;i<=n;i++)
                    dist[i]
            =0;
                 dist[s]
            =v;
                
                
            while(dist[s]<=v+eps)
                
            {
                 f
            =0;
                 
            for (int j=0;j<edge_vec.size();j++)
                 
            {
                     node edge
            =edge_vec.at(j);
                     relax(edge.u,edge.v,edge.r,edge.c);    
                 }

                 
            if (!f) break;
                }

               
            if (dist[s]>v+eps) return true;
                     
            else return false;
                
            }

            int main()
            {
                cin
            >>n>>m>>s>>v;
                
            for (int i=1;i<=m;i++)
                
            {
                    
            int x,y;
                    
            double rxy,cxy,ryx,cyx;
                    cin
            >>x>>y>>rxy>>cxy>>ryx>>cyx;
                    node edge;
                    edge.u
            =x;
                    edge.v
            =y;
                    edge.r
            =rxy;
                    edge.c
            =cxy;
                    edge_vec.push_back(edge);
                    edge.u
            =y;
                    edge.v
            =x;
                    edge.r
            =ryx;
                    edge.c
            =cyx;
                    edge_vec.push_back(edge);
                    
                }

                    
                
            if (bellman()) cout<<"YES"<<endl;
                   
            else
                       cout
            <<"NO"<<endl;
              
            // system("pause");
                return 0;
            }

            posted on 2009-10-04 17:23 Vincent 閱讀(122) 評論(0)  編輯 收藏 引用

            久久久久亚洲精品日久生情 | 99久久婷婷国产一区二区| 精品久久久久久中文字幕人妻最新| 久久精品黄AA片一区二区三区| 久久久久免费精品国产| 97香蕉久久夜色精品国产 | 久久综合久久美利坚合众国| 久久久久99精品成人片欧美| 精品无码久久久久久国产| 亚洲va中文字幕无码久久| 久久人妻少妇嫩草AV无码蜜桃| 精品国产一区二区三区久久久狼| 欧美日韩中文字幕久久久不卡| 久久w5ww成w人免费| 久久亚洲sm情趣捆绑调教| 国产精品VIDEOSSEX久久发布| 久久99精品国产自在现线小黄鸭| 亚洲国产精品综合久久网络| 国产2021久久精品| 久久99国产精一区二区三区| 久久综合久久自在自线精品自| 无码人妻久久一区二区三区蜜桃| 亚洲国产精久久久久久久| 精品无码久久久久国产| 久久久久久久久久久精品尤物| 久久亚洲国产精品五月天婷| 国产无套内射久久久国产| 久久精品国产99国产精品澳门| 久久精品国产久精国产思思| 久久久久无码精品国产不卡| 狠狠色丁香久久婷婷综合_中| 日本精品久久久久影院日本| 久久久久亚洲AV成人网| 久久久WWW成人免费精品| 久久精品中文字幕一区| 久久无码一区二区三区少妇| 欧美大战日韩91综合一区婷婷久久青草 | 久久久亚洲欧洲日产国码二区| 亚洲国产另类久久久精品黑人 | 狠狠色婷婷久久一区二区| 久久久久高潮综合影院|