ZOJ 3080 ChiBi(spfa)】的更多相关文章

ZOJ Problem Set - 3080 ChiBi Time Limit: 5 Seconds      Memory Limit: 32768 KB watashi's mm is so pretty as well as smart. Recently, she has watched the movie Chibi. So she knows more about the War of ChiBi. In the war, Cao Cao had 800,000 soldiers,…
从点(n,1)到点(1,m)的最短路径,可以转换地图成从(1,1)到(n,m)的最短路,因为有负权回路,所以要用spfa来判负环, 注意一下如果负环把终点包围在内的话, 如果用负环的话会输出无穷,但是有答案的,所以从终点出去的点不要,还有就是负环习惯用-1判断,但是可能会有负值,所以要用-inf #include<map> #include<set> #include<ctime> #include<cmath> #include<stack>…
POJ 1860 Currency Exchange / ZOJ 1544 Currency Exchange (最短路径相关,spfa求环) Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations onl…
ZOJ Problem Set - 3946 Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus…
Beer Problem Time Limit: 2 Seconds      Memory Limit: 32768 KB Everyone knows that World Finals of ACM ICPC 2004 were held in Prague. Besides its greatest architecture and culture, Prague is world famous for its beer. Though drinking too much is prob…
题目链接: POJ:http://poj.org/problem?id=1201 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=508 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.…
题意: 给定n个点,m条有向边,邮箱容量. 起点在1,终点在n,開始邮箱满油. 以下m行表示起点终点和这条边的耗油量(就是长度) 再以下给出一个数字m表示有P个加油站,能够免费加满油. 以下一行P个数字表示加油站的点标. 再以下一个整数Q 以下Q行 u v 表示在u点有销售站,能够卖掉邮箱里的随意数量的油,每以单位v元. 问跑到终点能获得最多多少元. 先求个每一个点的最大剩余油量 f[i], 再把边反向,求每一个点距离终点的最短路 dis[i]. 然后枚举一下每一个销售点就可以,( f[i] -…
//差分约束 >=求最长路径 <=求最短路径 结果都一样//spfa#include<stdio.h> #include<string.h> #include<limits.h> #include<queue> using namespace std; #define N 1010 #define M 1010*1010//注意边和点集的数组大小 struct edge { int to,value,next; }; struct edge ed…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5718   Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities…
人老了就比较懒,故意挑了到看起来很和蔼的题目做,然后套个spfa和dinic的模板WA了5发,人老了,可能不适合这种刺激的竞技运动了…… 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2760 Description Given a weighted directed graph, we define the shortest path as the path who has the smallest leng…
Burn the Linked Camp Time Limit: 2 Seconds      Memory Limit: 65536 KB It is well known that, in the period of The Three Empires, Liu Bei, the emperor of the Shu Empire, was defeated by Lu Xun, a general of the Wu Empire. The defeat was due to Liu Be…
Idiomatic Phrases Game Tom is playing a game called Idiomatic Phrases Game. An idiom consists of several Chinese characters and has a certain meaning. This game will give Tom two idioms. He should build a list of idioms and the list starts and ends w…
http://poj.org/problem?id=1932 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1935 题目大意: 看到XYZZY可不要以为是在玩扫雷哦. 给你一张图,初始你在房间1,初始生命值为100,进入每个房间会加上那个房间的生命(可能为负),要你进入房间n,问是否可能.(要求进入每个房间后生命值都大于0) 思路: 1.SPFA求最长路径,如果路径存在(即无环),那么肯定可以. 2.存在负环,不管她,…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
[热烈庆祝ZOJ回归] P1002:简单的DFS #include <cstdio> #include <cstring> #include <algorithm> ][]; int N; int input() { scanf("%d",&N); ;i<N;i++) scanf("%s",map[i]); return N; } ][]; ,sizeof(disable)); } int dfs(int cur)…
两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward is a truck driver of a big company. His daily work is driving a truck from one city to another. Recently he got a long d…
我觉得他整理的有一些乱,我都改成插入代码了,看的顺眼一些 转载自http://blog.csdn.net/juststeps/article/details/8772755 下面的都是原文: 最短路径 之 SPFA算法 http://hi.baidu.com/southhill/item/ab26a342590a5aae60d7b967 求最短路径的算法有许多种,除了排序外,恐怕是OI界中解决同一类问题算法最多的了.最熟悉的无疑是Dijkstra,接着是Bellman-Ford,它们都可以求出由…
HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with…
POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径) Description In the age of television, not many people attend theater perfor…
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description 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 exa…
POJ 2235 Frogger / UVA 534 Frogger /ZOJ 1942 Frogger(图论,最短路径) Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty a…
A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 10000 + 100; int SG[maxn]; vector<int> g[maxn]; int mex(int u) { //minimal exc…
The Exchange of Items Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 388564-bit integer IO format: %lld      Java class name: Main   Bob lives in an ancient village, where transactions are done by one item e…
新的整理版本版的地址见我新博客 http://www.hrwhisper.me/?p=1952 一.Dijkstra Dijkstra单源最短路算法,即计算从起点出发到每个点的最短路.所以Dijkstra常常作为其他算法的预处理. 使用邻接矩阵的时间复杂度为O(n^2),用优先队列的复杂度为O((m+n)logn)近似为O(mlogn) (一)  过程 每次选择一个未访问过的到已经访问过(标记为Known)的所有点的集合的最短边,并用这个点进行更新,过程如下: Dv为最短路,而Pv为前面的顶点.…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1770 题目大意: 陆逊为了火烧连营七百里,派出了间谍刺探敌情,得之刘备的军营以1~n编号一字排开,第i个大营最多能容纳Ci个士兵.而且通过观察刘备军队的动静,陆逊可以估计到从第i个大营到第j个大营至少有多少士兵.最后,陆逊必须估计出刘备最少有多少士兵,这样他才知道要派多少士兵去烧刘备的大营.为陆逊估计出刘备军队至少有多少士兵.然而,陆逊的估计可能不是很精确,如果不能很精确地估…
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944 In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitre…
3627: [JLOI2014]路径规划 Time Limit: 30 Sec  Memory Limit: 128 MBSubmit: 186  Solved: 70[Submit][Status][Discuss] Description 相信大家都用过地图上的路径规划功能,只要输入起点终点就能找出一条最优路线.现在告诉你一张地图的信息,请你找出最优路径(即最短路径).考虑到实际情况,一辆车加满油能开的时间有限,所以在地图上增加了几个加油站. 地图由点和双向边构成,每个点代表一个路口,也有可…
传送门 Til the Cows Come Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 46727   Accepted: 15899 Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…
题意:N点M边的无向图,边上有线性不下降的温度,给固定入口S,有E个出口.逃出去,使最大承受温度最小.输出该温度,若该温度超过H,输出-1. 羞涩的题意 显然N*H的复杂度dp[n][h]表示到达n最大温度为h的最小时间(由于温度不下降,这样不会更差,故可以这么搞) 一开始读错题了,以为是温度累加什么鬼... 然后分别写了2种方法,二分和不二分的 #include <cstdio> #include <cstring> #include <iostream> #incl…