HDU 5154 Harry and Magical Computer bfs】的更多相关文章

Harry and Magical Computer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 499    Accepted Submission(s): 233 Problem Description In reward of being yearly outstanding magic student, Harry gets…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5154 Harry and Magical Computer Description In reward of being yearly outstanding magic student, Harry gets a magical computer. When the computer begins to deal with a process, it will work until the end…
Harry and Magical Computer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description In reward of being yearly outstanding magic student, Harry gets a magical computer. When the computer begins to deal wi…
Description In reward of being yearly outstanding magic student, Harry gets a magical computer. When the computer begins to deal with a process, it will work until the ending of the processes. One day the computer got n processes to deal with. We num…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5154 题解: 有向图判环. 1.用dfs,正在访问的节点标记为-1,已经访问过的节点标记为1,没有访问过的节点标记为0,如果访问到-1的节点说明说有环. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; typedef long…
拓扑排序. /* 5154 */ #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <queue> #include <vector> using namespace std; #define MAXN 105 vector<int> vec[MAXN]; vector<int>::itera…
Harry and Magical Computer  Accepts: 350  Submissions: 1348  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 32768/32768 K (Java/Others) Problem Description In reward of being yearly outstanding magic student, Harry gets a magical computer. Whe…
例题:hdu 5154 链接  http://acm.hdu.edu.cn/showproblem.php?pid=5154 题目意思是第一行先给出n和m表示有n件事,m个关系,接下来输入m行,每行有a,b两个数,他们之间的关系就是第a件事要在 第b件事之前做完,然后问你可不可以在符合这m个关系的情况下把这n件事情做完,可以就输出YES,否则输出NO. 现在先假设a b之间的关系用a指向b来表示,即a-->b. 题目里给的两个样例有点简单,来个稍微复杂一点的好吧. 第一次搞这个,不太会,见谅.看…
HDU.2612 Find a way (BFS) 题意分析 圣诞节要到了,坤神和瑞瑞这对基佬想一起去召唤师大峡谷开开车.百度地图一下,发现周围的召唤师大峡谷还不少,这对基佬纠结着,该去哪一个...坤神:我要去左边的这个(因为离自己比较近 哈哈~)..瑞瑞:我要去右边的这个(因为离自己比较近 嘿嘿~) --..这对基佬闹矛盾了,开车有危险了! 为了不让他们去召唤师大峡谷坑人,riot决定让他们去X召唤师大峡谷,保证他俩所走的路程和最短.每走一个点需要花费11分钟,输出他们一共花费多少时间(最短时…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5154 题目意思:有 n 门 processes(编号依次为1,2,...,n),然后给出 m 种关系: a,b.表示 process b 要在 process a 之前完成.问经过 m 种关系之后,有没有可能完成所有的 process. 可以利用拓扑排序的思想做.遍历所有 process,处理所有入度为 0 的点,然后把与该点关联的点,即度数都减一.这样处理完之后,每个点的度数应该都是-1,否则就代…