CF37E Trial for Chief(最短路)】的更多相关文章

题意 题意是给你一张 NMNMNM 的图,每个点有黑色和白色,初始全为白色,每次可以把一个相同颜色的连续区域染色,求最少的染色次数:(n,m<=50) 题解 转化为最短路.对于每一个点与它相邻的相同颜色的点连权值为0的边,对于颜色不同的点连权值为1的点.从每一个点跑单源最短路,把到W点的距离和到B点的距离+1取min作为此点的答案,最后把每一个点的答案取max就是答案. 对于能直接到达的两个颜色相同的点显然只用涂一次,如果不同就要再涂一次,所以这样建图.为了特判全是黑色的情况,所以到B点的距离要…
Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Description Having unraveled the Berland Dictionary, the scientists managed to read the notes of the chroniclers of that time. For example, they learned how the chief of the…
如果固定了一个中心,那么只需要考虑从它开始最远染到的那些点究竟染了几次. 上下左右不同的点连1边,相同的连0边,跑单源最短路就可以啦. lyd讲的是统计到最远黑点+1的最小值,但是#58数据全是白点,嗯...应该这样考虑,黑点+1,白点不+1. 一开始数组开太大,导致memset时间暴增,没认真估计数据范围呢. #include<iostream> #include<cstring> #include<cstdio> #include<queue> #def…
想象成一层一层的染,所以相邻的两个格子连边,边权同色为0异色为1,然后答案就是某个格子到距离它最远得黑格子的最短距离的最小值 注意特判掉不需要染色的情况 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; const int N=55,inf=1e9; int n,m,id[N][N],tot,h[N*N],cnt,ans=inf…
CF147B Smile House 二分+矩阵快速幂,注意一下储存矩阵相乘结果的矩阵,初始化时,a[i][i]=-inf(而其他都可以a[i][i]=0,为了保证答案的可二分性). CF715B Complete The Graph 注意一下还没加的权值为0的边,权值赋为inf,否则可能影响前面生成的最短路. CF37E Trial for Chief 最短路模板不解释. 但是注意图上没有黑色的情况... [咕谷10月月赛||]游览器 二进制意义下,有奇数个1的数的个数,乘,有偶数个1的数的个…
赛前任务 tags:任务清单 前言 现在xzy太弱了,而且他最近越来越弱了,天天被爆踩,天天被爆踩 题单不会在作业部落发布,所以可(yi)能(ding)会不及时更新 省选前的练习莫名其妙地成为了Noip前的杂题训练,我也很无奈啊 做完了的扔最后,欢迎好题推荐 这么多题肯定是完不成了,能多做一道是一道吧 DP yyb真是强得不要不要的辣:http://www.cnblogs.com/cjyyb/category/1036536.html [ ] [SDOI2010]地精部落 https://www…
B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are…
D. Legacy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…
D. Legacy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…
D. Legacy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…