zoukankan      html  css  js  c++  java
  • gragh

    http://blog.sina.com.cn/s/blog_6cf509db0100uy5n.html

    网络流题目集合

    1: http://blog.csdn.net/shahdza/article/details/7779537

    2:http://blog.sina.com.cn/s/blog_5e518b010100m6w8.html

    http://blog.csdn.net/liwen_7/article/details/7298736

    http://blog.csdn.net/justlovetao/article/details/6697171

    http://ycool.com/post/m2uybbf(查分约束)

    bellman

    #include<iostream>
    #include<cstring>
    using namespace std;
    struct Node
    {
    	int u,v;
    	double ruv;
    	double need;
    }e[500];
    int n,s,m;
    double v;
    int all;
    double dist[111];
    bool bellman()
    {
    	int i,j;
    	memset(dist,0,sizeof(dist));
    	dist[s]=v;
    	for(i=0;i<n;i++)
    	{
    		for(j=0;j<all;j++)
    		{
    			if(dist[e[j].v]<(dist[e[j].u]-e[j].need)*e[j].ruv)
    				dist[e[j].v]=(dist[e[j].u]-e[j].need)*e[j].ruv;
    		}
    	}
    	for(j=0;j<all;j++)
    	{
    		if(dist[e[j].v]<(dist[e[j].u]-e[j].need)*e[j].ruv)
    				break;
    	}
    	if(j<all)
    		return true;
    	return  false;
    }
    int main()
    {
    	int i;
    	int x,y;
    	double nxy,cxy,nyx,cyx;
    	while(cin>>n>>m>>s>>v)
    	{
    		all=0;
    		for(i=0;i<m;i++)
    		{
    			cin>>x>>y>>cxy>>nxy>>cyx>>nyx;
    			e[all].u=x;e[all].v=y;e[all].ruv=cxy;e[all++].need=nxy;
    			e[all].u=y;e[all].v=x;e[all].ruv=cyx;e[all++].need=nyx;
    		
    		}
    			if(bellman())
    				cout<<"YES"<<endl;
    			else cout<<"NO"<<endl;
    	}
    	return 0;
    }
    
    
    
    
    

    堆void slift(int r[],int low,int high)
    {
        int i=low.j=2*i;
        int t=r[i];
        while(j<=high)
        {
            if(j<high&&r[j]<r[j+1])
                j++;
            if(tmp<r[j])
            {
                r[i]=r[j];
                i=j;
                j=2*i;
            }
            else break;
        }
        r[i]=tmp;
    }
    void Heapsort(int r[],int n)
    {
        int i;
        int t;
        for(i=n/2;i>=1;i--)//循环建立初始堆
            slift(r,i,n);
        for(i=n;i>=2;i--)//进行n-1 趟堆排序的元素个数减1
        {
            t=r[1];     //将最后一个元素同当前区间内r[1]兑换
            r[1]=r[i];
            r[i]=t;
            slift(r,1,i-1);
        }
    }

  • 相关阅读:
    C# 16进制与字符串、字节数组之间的转换
    多文件上传方法
    超链接如何下载文件txt,word,excel等等
    asp.net不同类型文件读取处理
    .net二进制图片存储与读取的常见方法
    c#事务
    C#中的null和数据库中的null的区别
    Asp.net中Response.Charset 与Response.ContentEncoding区别
    导出到word
    js导出word
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3857836.html
Copyright © 2011-2022 走看看