poj 36876 Labeling Balls
来源:互联网 发布:mac翻墙软件免费 编辑:程序博客网 时间:2024/06/09 18:41
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 than the one labeled with b".
Can you help windy to find a solution?
Input
The first line of input is the number of test case. The first line of each test case contains two integers, N (1 ≤ N ≤ 200) and M (0 ≤ M ≤ 40,000). The next M line each contain two integers a and b indicating the ball labeled with a must be lighter than the one labeled with b. (1 ≤ a, b ≤ N) There is a blank line before each test case.
Output
For each test case output on a single line the balls' weights from label 1 to label N. If several solutions exist, you should output the one with the smallest weight for label 1, then with the smallest weight for label 2, then with the smallest weight for label 3 and so on... If no solution exists, output -1 instead.
Sample Input
54 04 11 14 21 22 14 12 14 13 2
Sample Output
1 2 3 4-1-12 1 3 41 3 2 4
Source
- poj 36876 Labeling Balls
- poj 3687 Labeling Balls
- POJ 3687 Labeling Balls
- poj 3687 Labeling Balls
- POJ 3687 Labeling Balls
- poj-3687-Labeling Balls
- POJ 3687 Labeling Balls
- POJ 3687 Labeling Balls
- POJ 3687 Labeling Balls
- poj 3687 Labeling Balls
- POJ 3687 Labeling Balls
- poj 3687 Labeling Balls
- poj 3687 Labeling Balls
- POJ 14 Labeling Balls
- poj 3687 Labeling Balls
- POJ 3687 Labeling Balls
- POJ-3684 Labeling Balls
- poj 3687 Labeling Balls
- 如何同时安装Office2003和Office2007!
- Spring.NET学习笔记13——AOP的概念(基础篇)
- 批量删除PDF注释
- 快毕业了...
- 串口调试助手VC源程序及详细编程过程
- poj 36876 Labeling Balls
- 出现频率最高的笔试题strcpy写法
- MAX1480EA/MAX1480EC/MAX1490EA/MAX1490EB简单的参数翻译
- Java主线程与子线程的通信
- Win32串口编程
- 基于.NET平台的分层架构实战(一)——综述
- SQL+C#获得当前月的第一天与最后一天
- 深入浅出VC++串口编程之基于Win32 API
- 基于.NET平台的分层架构实战(二)——需求分析与数据库设计