hdu 3478 Catch(染色 dfs 或 bfs )】的更多相关文章

链接 : Here! 思路 : 搜索判断连通块个数, 所以 $DFS$ 或则 $BFS$ 都行喽...., 首先记录一下整个地图中所有$Oil$的个数, 然后遍历整个地图, 从油田开始搜索它所能连通多少块其他油田, 只需要把它所连通的油田个数减去, 就ok了 /************************************************************************* > File Name: E.cpp > Author: > Mail: >…
Problem Description A thief is running away! We can consider the city to N–. The tricky thief starts his escaping if and only if there is a street between cross u and cross v. Notice that he may not stay at the same cross in two consecutive moment. T…
题目链接 题意 小偷逃跑,从某个点出发,每下一个时刻能够跑到与当前点相邻的点. 问是否存在某一个时刻,小偷可能在图中的任意一个点出现. 思路 结论 如果该图为连通图且不为二分图,则可能,否则不可能. 原因 首先显见图需要连通. 下证:小偷可能在图中任意一个点出现当且仅当该连通图不为二分图. 必要性:如果该图是个二分图,那么将图中所有点染成白点和黑点.假设小偷起始时刻在白点,那么下一时刻必然在黑点,下下时刻必然在白点--即每个时刻小偷只可能在白点或黑点,即不可能出现在图中任意一个点. 充分性:如果…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2717 Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12615    Accepted Submission(s): 3902 Problem Description Farmer John has been…
http://acm.hdu.edu.cn/showproblem.php?pid=3478 题意 给一个无向图和小偷的起点,小偷每秒可以向相邻的点出发,问有没有一个时间点小偷可能出现在任何点. 分析 首先图得要是联通的,由于是无向的,那么只需记录图中是否存在悬挂点(度为0),存在的话就不联通了,输出NO.只要图是二分图,小偷就不可能在某一时刻可能出现在任意位置,因为如果是二分图,在移动时必然是从一类结点走向另一类,这样任何时刻都存在一个走不到的点.于是用染色法判断是否为二分图即可.此外,还有判…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2717 Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20259    Accepted Submission(s): 5926 Problem Description Farmer John has been i…
Catch That Cow Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer…
Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6383    Accepted Submission(s): 2034 Problem Description Farmer John has been informed of the location of a fugitive cow and wants…
Problem Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. F…
1.题意:一位公主被困在迷宫里,一位勇士前去营救,迷宫为两层,规模为N*M,迷宫入口为(0,0,0),公主的位置用'P'标记:迷宫内,'.'表示空地,'*'表示墙,特殊的,'#'表示时空传输机,走到这里就会被传输到另一层的相对位置:在迷宫内没走动一步耗时为1,最终求解是否能在T时刻解救到公主: 2.输入输出:第一行C表示C组数据,每一组内N,M,T给出的迷宫规模与时间,接着给出了双层迷宫的内容:若是能找到公主输出"YES",否则"NO": 3.分析:这里原题意判断是…