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 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…
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 题解: 有向图判环. 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…
例题: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. 题目里给的两个样例有点简单,来个稍微复杂一点的好吧. 第一次搞这个,不太会,见谅.看…
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…
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For exa…
题目链接: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,否则就代…