bzoj2100 [Usaco2010 Dec]Apple Delivery】的更多相关文章

Description Bessie has two crisp red apples to deliver to two of her friends in the herd. Of course, she travels the C (1 <= C <= 200,000) cowpaths which are arranged as the usual graph which connects P (1 <= P <= 100,000) pastures convenientl…
题目描述 一张P个点的无向图,C条正权路.CLJ要从Pb点(家)出发,既要去Pa1点NOI赛场拿金牌,也要去Pa2点CMO赛场拿金牌.(途中不必回家)可以先去NOI,也可以先去CMO.当然神犇CLJ肯定会使总路程最小,输出最小值. 题解:做两遍spfa,找出从起点开始先去pa1或者先去pa2的最小值 需要用一下spfa的优化,每次进行入队的时候都与队头进行比较,如果比队头小就放在队头,否则放队尾. #include<bits/stdc++.h> using namespace std; #de…
跑两遍最短路就好了.. 话说这翻译2333 ---------------------------------------------------------------------- #include<cstdio> #include<queue> #include<algorithm> #include<cstring> #include<iostream>   #define rep( i , n ) for( int i = 0 ; i…
题目描述 Bessie has two crisp red apples to deliver to two of her friends in the herd. Of course, she travels the C (1 <= C <= 200,000) cowpaths which are arranged as the usual graph which connects P (1 <= P <= 100,000) pastures conveniently numbe…
http://www.lydsy.com/JudgeOnline/problem.php?id=2100 这题我要吐血啊 我交了不下10次tle.. 噗 果然是写挫了. 一开始没加spfa优化果断t 然后看了题解加了(加错了T_T)还是tle..我就怀疑数据了... 噗 原来我有个地方打错了.. 这个spfa的队列优化真神.. #include <cstdio> #include <cstring> using namespace std; #define rep(i, n) fo…
洛谷数据好强啊,普通spfa开o2都过不了,要加双端队列优化 因为是双向边,所以dis(u,v)=dis(v,u),所以分别以pa1和pa2为起点spfa一遍,表示pb-->pa1-->pa2和pb-->pa2-->pa1,取个min即可 #include<iostream> #include<cstdio> #include<queue> using namespace std; const int N=200005,inf=2e9+7; in…
由于是无向图,所以可以枚举两个终点,跑两次最短路来更新答案. #include <queue> #include <cstdio> #include <cstring> #include <algorithm> #define N 100006 #define M 200007 #define setIO(s) freopen(s".in","r",stdin) using namespace std; deque&l…
洛谷 P3003 [USACO10DEC]苹果交货Apple Delivery 洛谷传送门 JDOJ 2717: USACO 2010 Dec Silver 1.Apple Delivery JDOJ传送门 Description Bessie has two crisp red apples to deliver to two of her friends in the herd. Of course, she travels the C (1 <= C <= 200,000) cowpat…
我猜我这样继续做水题会狗带 和模拟赛的题很像,贪心搞一下. #include<bits/stdc++.h> using namespace std; int read(){ ,f=;char ch=getchar(); ;ch=getchar();} +ch-';ch=getchar();} return x*f; } #define N 100005 int n,m,f[N],q[N],cnt; struct Node{ int to,next; }e[N<<]; int tot…
2101: [Usaco2010 Dec]Treasure Chest 藏宝箱 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 327  Solved: 147[Submit][Status] Description Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk i…