如果总的入队次数大于所以点两倍时有负,或单个点的入队次数大于sqrt(点数)有负
原创 2023-02-24 11:24:48
8阅读
SPFA是很简单的:普通队列,用du + w更新dv即可。判断是否in queue可以提高速度。 1 void spfa() { 2 memset(d, 0x3f, sizeof d); d[1] = 0; 3 q.push(1); inq[1] = true; 4 while (!q.empty( ...
转载 2021-09-24 00:15:00
87阅读
2评论
题目链接:http://poj.org/problem?id=3259Time Limit:2000MSMemory Limit:65536KDescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very pe...
原创 2022-02-03 15:09:27
61阅读
题目链接:http://poj.org/problem?id=3259Time Limit:2000MSMemory Limit:65536KDescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very pe...
原创 2021-07-14 10:49:30
57阅读
一、内容Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 B...
原创 2021-08-27 14:21:58
88阅读
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25957思路:由于路线为一个,将路径上的权值改为c-p*d,那么然后建图,那么我们只需判断图中是否存在权值和为正的,这个用spfa即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define MAXN 222 9 #define inf 1 >g;22 23 void spfa(int st)24 {25 me.
转载 2013-09-26 19:09:00
69阅读
2评论
题目链接:http://poj.org/problem?id=2240Time Limit:1000MSMemory Limit:65536K Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more ...
原创 2021-07-14 10:48:58
121阅读
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchang
原创 2021-09-01 15:06:17
108阅读
一、内容Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 B...
原创 2022-01-06 16:46:10
50阅读
题目链接:http://poj.org/problem?id=2240Time Limit:1000MSMemory Limit:65536K Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more ...
原创 2022-02-03 15:04:04
119阅读
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26823思路:题目的意思是求出所有的能够到达负的点。负很好求,spfa即可,然后要求那些可以到达负的点,其实我们可以反过来想,从负出发,看能够达到那些顶点。于是我们可以建反图搞定。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define MAXN 1111 9 #define inf 1 >g;22 23 vo
转载 2013-09-26 18:30:00
78阅读
2评论
题意: 有n个点 m条边 每个边有权值 一开始有一百血 每次经过一条路都会加上其权值 判断是否能够到达n 显然 有正的时候肯定能够到达 最短路好题!!!!!!! 显用folyed判断是否联通 然后用spfa更新最长路 因为每次更新的都是最长路 所有有的时候肯定是正 这时候直接return即可
转载 2019-04-27 21:33:00
92阅读
2评论
题意: 给你一幅图,dis(u->v)的权值就是(w[v]-w[u])*(w[v]-w[u])*(w[v]-w[u]),所以有可能是负的,给你n个询问,给出最短路,长度using namespace std;typedef long long LL;typedef unsigned long l...
转载 2016-11-29 22:48:00
56阅读
注意不axn], num
原创 2022-08-17 15:45:31
50阅读
题目链接:
原创 2023-03-03 15:13:47
179阅读
思路:SPFA 数组不要开太小……(后面附一组测试数组)// by SiriusRen#include #include #include using namespace std;#define N 13555int n,cases,m,W,xx,yy,zz,tot,firs...
转载 2016-08-07 12:36:00
21阅读
2评论
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=499 题意:就是推断图中有无负 SPFA,某个节点入队次数大于n就是有负。 代码: #in
转载 2018-02-02 08:52:00
79阅读
2评论
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchang
转载 2018-08-08 23:06:00
152阅读
2评论
Description While exploring his many farms, Farmer John h
转载 2018-10-21 21:31:00
95阅读
2评论
#第一以为是直接传送看贝西会不会无限循环那道题,直接洛谷搬过来交了一发,wa了 哦,不是,是时间旅行者JOHN. #建图+ 虫洞单向边,权值为负; 路径双向边,权值为正; #的条件是入队次数>n 坑点: 听说poj的评测机菜到动用min不行要手写if; 还听说连三目运算都会被卡; 我的坑 ...
转载 2021-10-07 14:12:00
75阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5