当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2343:Airline company

Special Judge 特殊评判
题目描述
An airline company is a sponsor of the 80-th Anniversary celebration at the Ural State University. In return for it the company wants the University to help it. The company serves n airports and carries out flights between some of them. In order to simplify the work the flights are numbered with integers from 1 up to m. If there is a flight between two airports a plane flies in the both directions with the same flight number. There may be only one flight between any two airports.
The airline company understands that its planes may attract terrorists. In order to create difficulties for terrorists the company wants to number the flights in some special manner. If there are several flights that depart from one airport then the greatest common divisor of their flight numbers should be equal to 1. The company turns to you for help (remember, this is a sponsor; you are to work properly).
You should write a program that finds a required numbering or informs that it is impossible to satisfy the requirements. If several numberings are possible, it is sufficient to find any one of them.
输入解释
The first line of input contains numbers n and m separated with a space (2 <= n <= 50). The next m lines contain information on flights. Each flight is determined by the numbers of the airports that it connects. The numbers of the airports are separated with a space.
输出解释
The first line of an output should contain YES, if it is possible to find a required numbering, and NO otherwise. If the answer is YES, the second line should contain a possible numbering of flights. The numbers are to be ordered as it is done in the input. Flight numbers are to be separated with a space.
输入样例
6 5
1 2
2 3
2 4
4 3
5 6
输出样例
YES
4 2 3 1 5

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2343

最后修改于 2020-10-29T06:30:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536