1323: 邹小竞老师的别墅
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:1
Solved:1
Description
不允许普通用户打印题目,请教师登录后使用。如有疑问请联系管理员!
Input
输入给出若干个别墅的描述。每个别墅描述的第一行给出3个整数r、d和s;其中是别墅里的房间数,最多有10间;d是连接两间房间的门的数量;而s是别墅里灯的开关数。房间编号由1到r;编号为1的房间是走廊,编号为r的房间是卧室。后面给出的d行,每行给出两个整数i和j,表示房间i和房间j有一扇门连接。然后给出的s行,每行给出两个整数k和1,表示在房间k中有个开关控制房间1中的灯。在两个别墅描述之间用一行空行分隔。输入以别墅描述r=d=s=0结束,程序对此不必处理。
Output
对于每栋别墅,首先在一行中输出测试用例的编号(“Villa#1”、“Villa#2”等)。如果邹小竞老师的问题有解,则输出使得她进入卧室步数最少且只有卧室的灯开着的步序列(如果你找到的步序列不止一个,仅输出一条最短的步序列)。请按照输出样例中给出的输出格式。如果没有解,则输出一行“The problem cannot be solved.”。在每个测试用例之后,输出一个空行。
Sample Input Copy
3 3 4
1 2
1 3
3 2
1 2
1 3
2 1
3 2
2 1 2
2 1
1 1
1 2
0 0 0
Sample Output Copy
Villa #1
The problem can be solved in 6 steps:
- Switch on light in room 2.
- Switch on light in room 3.
- Move to room 2.
- Switch off light in room 1.
- Move to room 3.
- Switch off light in room 2.
Villa #2
The problem cannot be solved.