博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Wedding 2-SAT的题目
阅读量:4976 次
发布时间:2019-06-12

本文共 1539 字,大约阅读时间需要 5 分钟。

Wedding
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7850   Accepted: 2375   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 63h 7h5w 3w7h 6w8w 3w7h 3w2w 5h0 0

Sample Output

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

Source

, 2007.9.29

转载于:https://www.cnblogs.com/DreamHighWithMe/p/3660704.html

你可能感兴趣的文章
alembic 实践操作
查看>>
【数据库】:关于DB2数据库错误提示说明
查看>>
C基础-标准C语言头文件
查看>>
BZOJ4590: [Shoi2015]自动刷题机
查看>>
java 删除文件目录
查看>>
免安装mysql配置
查看>>
Tomcat安装和常见问题
查看>>
Linux进程管理
查看>>
并查集详细讲解(数据结构篇)
查看>>
php程序员应具有的7种能力
查看>>
CSS3 GRID LAYOUT
查看>>
自动刷新session
查看>>
git 命令
查看>>
【python小练】0005
查看>>
2016012102 小学四则运算练习软件项目报告
查看>>
Struts2下载
查看>>
Java面试题
查看>>
websocket 前后台代码实例
查看>>
__strong修饰符
查看>>
快速又改动少的将窗口改成融合窗
查看>>