Description N students were invited to attend a party, every student has some friends, only if someone’s all friends attend this party, this one can attend the party(ofcourse if he/she has no friends, he/she also can attend it.), now i give the frien…
H.Skiing In this winter holiday, Bob has a plan for skiing at the mountain resort. This ski resort has MM different ski paths and NN different flags situated at those turning points. The ii-th path from the S_iSi-th flag to the T_iTi-th flag ha…
Description There is a river, which contains n stones from left to right. These stones are magic, each one has a magic number Ai which means if you stand on the ith stone, you can jump to (i +1)th stone, (i+2)th stone, ..., (i+Ai)th stone(when i+Ai >…
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2647 老板给员工发工资,每个人的基本工资都是888,然后还有奖金,然后员工之间有矛盾,有的员工希望比某员工的奖金多,老板满足了所以员工的这种心思,而且老板下午发的总工资最少,问最少是多少?比如 a b 表示a的工资比b要高(高一块钱),当出现a b b c c a这种环的时候输出-1 拓扑排序http://www.cnblogs.com/tonghao/p/4721072.html 小指向大…
拓扑排序: 按照有向图给出的次序关系,将图中顶点排成一个线性序列,对于有向图中没有限定次序关系的顶点,则可以人为加上任意的次序关系,由此所得顶点的线性序列称之为拓扑有序序列.显然对于有回路的有向图得不到拓扑有序序列,因为有回路的话,顶点的先后次序就不确定了. 例如:例如,下图,我们可以人为限定次序:A B C D 或 A C B D 解释:该输出顺序特点就是后面的顶点输出必然后于该顶点的前驱顶点 算法: 从有向图中选取一个没有前驱(没有在它之前活动)的顶点,输出之: 从有向图中删去此顶点以及所有…
Reward Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13509 Accepted Submission(s): 4314 Problem Description Dandelion's uncle is a boss of a factory. As the spring festival is coming , he w…