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

建议使用的浏览器:

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

2396:Dominoes

题目描述
A domino contains two ends, each labeled with number between 1 and 6. You are to write a program that determines if a set of dominoes can be organized in a line so that all dominoes are used; numbers on successive dominoes match; and the numbers on both ends match. You are allowed to rearrange and flip the dominoes arbitrarily. For example, the five dominos: (3 3), (3 1), (4 3), (1 6), and (4 6) can be arranged as:

The five dominos: (4 5), (3 4), (1 2), (2 3), and (5 5) cannot be arranged with all ends matching.
输入解释
The input contains a list of domino-sets. The first line of each set contains a single integer corresponding to the number of dominos in the set – 3 <= N <= 10. The next N lines each contain the two values on a single domino. The end of input is denoted by N = 0.
输出解释
Your program should produce one line of output for every set of dominos. The format should be: “Set #1: YES” or “Set #1: NO”.
输入样例
3
1 2
3 2
3 1
5
4 5
3 4
1 2
2 3
5 5
5
3 3
3 1
4 3
1 6
4 6
0
输出样例
Set #1: YES
Set #2: NO
Set #3: YES
来自杭电HDUOJ的附加信息
Author 2008 ACM ICPC Regional hangzhou
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2396

最后修改于 2020-10-25T22:53:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)