posts - 74,  comments - 33,  trackbacks - 0
Wedding
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 821 Accepted: 249 Special Judge

Description

Up to thirty couples will attend a wedding feast, at which they will be seated on either side of a long table. The bride and groom sit at one end, opposite each other, and the bride wears an elaborate headdress that keeps her from seeing people on the same side as her. It is considered bad luck to have a husband and wife seated on the same side of the table. Additionally, there are several pairs of people conducting adulterous relationships (both different-sex and same-sex relationships are possible), and it is bad luck for the bride to see both members of such a pair. Your job is to arrange people at the table so as to avoid any bad luck.

Input

The input consists of a number of test cases, followed by a line containing 0 0. Each test case gives n, the number of couples, followed by the number of adulterous pairs, followed by the pairs, in the form "4h 2w" (husband from couple 4, wife from couple 2), or "10w 4w", or "3h 1h". Couples are numbered from 0 to n - 1 with the bride and groom being 0w and 0h.

Output

For each case, output a single line containing a list of the people that should be seated on the same side as the bride. If there are several solutions, any one will do. If there is no solution, output a line containing "bad luck".

Sample Input

10 6
3h 7h
5w 3w
7h 6w
8w 3w
7h 3w
2w 5h
0 0

Sample Output

1h 2h 3w 4h 5h 6h 7h 8h 9h

Source

Waterloo Local Contest, 2007.9.29
。。。。。。。。。。。。。。。。。。。。
郁闷。。。。。。。。。。。。。。。。。。
搞的一下午。。。。。。。。。。。。。。。错了N次。。。。
题目很WS最后从读一遍。。。。。。。。。终于读懂。。。。。
饿死我了。。。。。。。。。。。。。。还不会构图。。。。。。
先吃饭,回来在搞。。。。。。。,今天就这5道题还困难了。。。郁闷。
--------------------------------------------------------------------------------------------------------------------------------------------------------------
2009.6.8  22:34  
代码很丑不贴了,再有6分钟就熄灯了。。。。。躺下想了一会感觉一起思路是对的就是没有考虑0w-》0h的这条边。。。。
结果一改之。。。。。。。。。。AC  
5281113xujiaming3648Accepted364K0MSC++2635B2009-06-08 22:33:58    

2009-06-08 22:33:58 AC时间  AC完了之后说了两个字“我日”耗费了两秒钟。然后直接打开Blog。今晚终于搞出来了
感谢指出Bug的大牛。
啊,自习了、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
posted on 2009-06-07 17:19 KNIGHT 阅读(1261) 评论(3)  编辑 收藏 引用

FeedBack:
# re: poj 3648 Wedding
2009-06-07 22:29 | Knignt
6道2-SAT独此道没刷。。。。。。郁闷
待到花明时,再议  回复  更多评论
  
# re: poj 3648 Wedding
2009-08-25 20:53 | inowfordream
借问一下大牛,为什么0w-》0h的这条边一定要选?  回复  更多评论
  
# re: poj 3648 Wedding[未登录]
2009-08-25 21:37 | Knight
@inowfordream
有个条件说夫妻不能在一边吧 。。。。这题很久了。。  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(8)

随笔档案

文章档案

Friends

OJ

搜索

  •  

最新评论

阅读排行榜

评论排行榜