• <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 閱讀(118) 評論(0)  編輯 收藏 引用

            亚洲中文字幕无码一久久区| 国产精品内射久久久久欢欢| 亚洲国产精品久久久久婷婷老年| 97久久久久人妻精品专区 | 99久久综合国产精品二区| 色婷婷综合久久久久中文一区二区| 97久久国产亚洲精品超碰热| 国产99久久久久久免费看| 国产精品久久久久蜜芽| 99久久精品毛片免费播放| 久久亚洲2019中文字幕| 国产成人精品久久免费动漫| 欧美色综合久久久久久| 国产ww久久久久久久久久| 狠狠色丁香久久婷婷综合图片| 国产精品免费福利久久| 精品国产乱码久久久久久1区2区 | 久久青青草原精品国产不卡| 久久伊人五月丁香狠狠色| 国产精品久久久久久久久鸭| 性做久久久久久久久浪潮| 久久久久亚洲AV无码去区首| 久久这里只有精品18| 亚洲午夜无码AV毛片久久| 亚洲精品国精品久久99热| 国产精品一久久香蕉国产线看| 国产精品九九久久免费视频 | 亚洲午夜无码久久久久小说| 久久精品国产一区| 精品国际久久久久999波多野| 久久99热这里只有精品66| 久久久久国色AV免费观看| 色婷婷综合久久久久中文字幕 | 久久婷婷国产综合精品| 欧美丰满熟妇BBB久久久| 人人妻久久人人澡人人爽人人精品| 99久久精品免费观看国产| 久久国产成人精品麻豆| 热re99久久精品国产99热| 久久精品一区二区影院| 国产午夜精品久久久久九九|