poj 1860 最短路
来源:互联网 发布:内向者适合做淘宝吗 编辑:程序博客网 时间:2024/05/21 05:20
2015/1/26
算法不难,主要别用矩阵去建边就好= =用矩阵很烦(没写出来)。
#include<map>#include<queue>#include<stack>#include<cmath>#include<vector>#include<climits>#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;typedef long long ll; #define mod 10007#define lson pos<<1,l,mid#define sc(n) scanf("%d",&n)#define rson pos<<1|1,mid+1,r#define pr(n) printf("%d\n",n)#define met(n,m) memset(n, m, sizeof(n))#define F(x,y,i) for(int i = x;i > y; i--)#define f(x,y,i) for(int i = x;i < y; i++)#define ff(x,y,i) for(int i = x;i <= y; i++)#define FF(x,y,i) for(int i = x;i >= y; i--) const int N=100500;const int inf = INT_MAX;int Max(int a,int b){return a>b?a:b;}int Min(int a,int b){return a<b?a:b;}int n, m, tot;struct node{int from,to;double rate; double commission;}s[1000];double dis[1000];void BF(int x,double num){met(dis,0);dis[x]= num;f(1,n,i){int temp = 1;f(0,tot,j){if(dis[s[j].to] < (dis[s[j].from] - s[j].commission)* s[j].rate){dis[s[j].to] = (dis[s[j].from] - s[j].commission)* s[j].rate;temp = 0;}}if(temp)break;}f(0,tot,i){if(dis[s[i].to] < (dis[s[i].from] - s[i].commission)* s[i].rate){printf("YES\n");return ;}}printf("NO\n");return ;}int main() { int a, b , x; double num, r, c; while(~scanf("%d%d%d%lf",&n,&m,&x,&num)) { tot = 0; f(0,m,i) { scanf("%d%d%lf%lf",&a,&b,&r,&c); s[tot].from = a; s[tot].to = b; s[tot].rate = r; s[tot++].commission = c; scanf("%lf%lf",&r,&c); s[tot].from = b; s[tot].to = a; s[tot].rate = r; s[tot++].commission = c; } BF(x, num); } return 0; }
0 0
- poj 1860 最短路
- POJ 1860 最短路
- poj 1860(最短路)
- POJ-1860(最短路)
- poj 1860 -- Currency Exchange(最短路)
- poj 1860 最短路
- poj 1860 Currency Exchange (最短路)
- POJ 1860 Currency Exchange(最短路)
- POJ 1860 Currency Exchange(最短路SPFA)
- POJ 1860Currency Exchange BFS最短路
- POJ - 1860 Currency Exchange(最短路)
- poj 1860 Currency Exchange(最短路)
- poj 1860Currency Exchange(bellman 最短路)
- POJ 1860 Currency Exchange(最短路)
- POJ-1860-Currency Exchange [最短路][BellmanFord]
- poj 2253 最短路
- POJ 1135 最短路
- POJ 2267 最短路
- 校企结合培养创新型生物制药高技能人才
- mkinitramfs脚本文件分析,位置/usr/sbin/mkinitramfs
- iOS开发之手势篇
- 设计模式心得:策略模式 (strategy pattern)
- 在Ubuntu上安裝Eclipse
- poj 1860 最短路
- 1.25
- 一个关于家具的横幅广告
- 抓包神器fiddler
- UIScrollView的重要属性总结,以及UIScrollViewDelegate协议的使用
- 《时间管理》读后感
- POJ 3208 Apocalypse Someday(数位DP)
- 跳动的球
- 如何设置UINavigationBar背景怎么换