icpc2018-焦作-F Honeycomb bfs】的更多相关文章

题目大意: 给定n m表示一共n行每行m个蜂巢 求从S到T的最短路径 input 1 3 4 +---+ +---+ / \ / \ + +---+ +---+ \ \ / \ + + S +---+ T + / \ / / + +---+ + + \ \ / \ +---+ +---+ + / / + +---+ + + \ / \ +---+ +---+ + \ / \ / +---+ +---+ output 7 如图所示,其实只要按平常的走迷宫改变一下位移的格数就行了 改成一下的 上,下…
http://codeforces.com/gym/102028/problem/F 就是一个bfs,主要问题是建图,要注意奇数和偶数列的联通方案是略有不同的.比赛的时候写完一直不过样例最后才发现没考虑奇偶,心态炸裂. #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<set> #include<stack> #include<…
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Description We all know that King Triton doesn't like us and therefore shipwrecks, hurricanes and tsunami do happen. But being bored with the same routine…
题目链接 题解:这道题比赛的时候,学弟说是网络流,当时看N这么大,觉得网络流没法做,实际本题通过巧妙的建图,然后离散化. 先说下建图方式,首先每个覆盖区域,只有左右端点,如果我们只用左右端点的话,最多有400个点,所以第一步离散化.每个$i$和$i+1$连一条边流量为K,费用为0的边,每一个覆盖区域从左端点$u$向右端点$v$连一条流量为1,费用为$-w$的边,因为一般算最大费用,就要把边权变成负的算最小,最后取反是最大.对了,右端点$v$要+1,因为这个覆盖区域是从$u->v$,我应该从$v+…
第一发又超时了... 题目大意:给你n个点,然后给你n-1的数,表示两两距离,然后让你输出n个答案,第i个答案表示从这n个点里面挑i个点,然后这i个点两两之间会有一个距离,答案要求这些距离和的最大值. 第一次思路:n个点,给你距离,我们可以得到在坐标轴上表示n个点的坐标,然后我们可以先设每个点坐标为xi 可以发现:当n>=2的时候 n=2,i=2 距离为x2-x1 n=3,i=2距离为x3-x1 i=3距离为 x2-x1+x3-x1+x3-x2=2*x3-2*x1 n=5,i=2距离为x5-x1…
// 2019.10.7 练习赛 // 赛题来源:2018 ICPC 焦作区域赛 // CF链接:http://codeforces.com/gym/102028 A Xu Xiake in Henan Province 题目大意 有四个旅游地,给出 n 个人去四个地方的旅游次数,根据他去过旅游地个数输出相应等级. 思路 签到题...(队友在干嘛呀,10min过去了600人交题了啊我们怎么还没AC AC代码 #include<iostream> #include<cstdio> u…
//POJ3083 //DFS求靠左墙(右墙)走的路径长+BFS求最短路 //Time:0Ms Memory:716K #include<iostream> #include<cstring> #include<cstdio> #include<queue> using namespace std; #define MAX 45 #define INRANGE(x,y) (x >= 0 && x < n && y…
1128 写的dfs貌似不太对 bfs重写 用bfs将图进行黑白染色 如果有超过一个与自己颜色相同的点 就把该点存入栈中 最后处理栈中的点 判断此点是否合法 不合法 取反 取反后再判断相邻点是否合法 不合法再存入栈中 直到栈为空 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<vect…
/* ID: shangca2 LANG: C++ TASK: msquare */ #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<queue> #define INF 0xfffffff using namespace std; ]; typedef struct node…
非常可乐 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 42   Accepted Submission(s) : 21 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却…