poj 3687 Labeling Balls【反向拓扑】】的更多相关文章

Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the same label. The labeling satisfies several constrains like "The ball labeled with a is lighter than the on…
题意:给出n个人,m个轻重关系,求满足给出的轻重关系的并且满足编号小的尽量在前面的序列 因为输入的是a比b重,但是我们要找的是更轻的,所以需要逆向建图 逆向建图参看的这一篇http://blog.csdn.net/scf0920/article/details/28108243 然后用优先队列来实现的参看的这一篇 http://ycool.com/post/u9ahrwg#algo3 #include<iostream> #include<cstdio> #include<c…
Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the same label. The labeling satisfies several constrains like "The ball labeled with a is lighter…
(点击此处查看原题) 题意 此处有n盏灯,编号为1~n,每盏灯的亮度都是唯一的,且在1~n范围之间,现已知m对灯之间的关系:a b ,说明灯a的亮度比灯b小,求出每盏灯的亮度,要求字典序最小(编号小的灯亮度尽量小),使之满足m对关系,如果不存在,输出-1 解题思路 每对灯的关系:a b ,说明灯a的亮度比灯b小,同时也说明a的完成时间比b早(AOV网中的概念),这种关系可以用拓扑排序很好地处理,而由于这个题目要求字典序最小,为此将队列改为优先队列,使得编号大的灯先出队,并为其赋予较大的拓扑序,这…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10161   Accepted: 2810 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 toN in such a way that: No two balls share…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16100   Accepted: 4726 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12246   Accepted: 3508 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14835   Accepted: 4346 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share…
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9641 Accepted: 2636 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15792   Accepted: 4630 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share…