UVa 592 Island of Logic:有趣的枚举题

592 - Island of Logic

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=533

The Island of Logic has three kinds of inhabitants: divine beings that always tell the truth, evil beings that always lie, and human beings that are truthful during the day and lie at night. Every inhabitant recognizes the type of every other inhabitant.

A social scientist wants to visit the island. Because he is not able to distinguish the three kinds of beings only from their looks, he asks you to provide a communication analyzer that deduces facts from conversations among inhabitants. The interesting facts are whether it is day or night and what kind of beings the speakers are.

Input

The input file contains several descriptions of conversations. Each description starts with an integer n, the number of statements in the conversation. The following n lines each contain one statement by an inhabitant. Every statement line begins with the speaker's name, one of the capital letters A, B, C, D, E, followed by a colon `:'. Next is one of the following kinds of statements:

I am [not] ( divine | human | evil | lying ).

X is [not] ( divine | human | evil | lying ).

It is ( day | night ).

Square brackets [] mean that the word in the brackets may or may not appear, round brackets () mean that exactly one of the alternatives separated by | must appear. X stands for some name from A, B, C, D, E. There will be no two consecutive spaces in any statement line, and at most 50 statements in a conversation.

The input is terminated by a test case starting with n = 0.

Output

For each conversation, first output the number of the conversation in the format shown in the sample output. Then print ``This is impossible.'', if the conversation cannot happen according to the rules or ``No facts are deducible.'', if no facts can be deduced. Otherwise print all the facts that can be deduced. Deduced facts should be printed using the following formats:

X is ( divine | human | evil ).

It is ( day | night ).

X is to be replaced by a capital letter speaker name. Facts about inhabitants must be given first (in alphabetical order), then it may be stated whether it is day or night.

The output for each conversation must be followed by a single blank line.

Sample Input

1
A: I am divine.
1
A: I am lying.
1
A: I am evil.
3
A: B is human.
B: A is evil.
A: B is evil.
0

Sample Output

Conversation #1
No facts are deducible.

Conversation #2
This is impossible.

Conversation #3
A is human.
It is night.

Conversation #4
A is evil.
B is divine.

Reasoning made easy

To make things clearer, we will show the reasoning behind the third input example, where A says ``I am evil.''. What can be deduced from this? Obviously A cannot be divine, since she would be lying, similarly A cannot be evil, since she would tell the truth. Therefore, A must be human, moreover, since she is lying, it must be night. So the correct output is as shown.

In the fourth input example, it is obvious that A is lying since her two statements are contradictory. So, B can be neither human nor evil, and consequently must be divine. B always tells the truth, thus A must be evil. Voil‘a!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索is
, ground truth
, must not
, The
, be
that
island of adventure、aegean island of kea、bay of island、the island of totora、island of love歌词,以便于您获取更多的相关知识。

时间: 2024-10-29 23:13:47

UVa 592 Island of Logic:有趣的枚举题的相关文章

一个有趣的排序题,类似acm

问题描述 一个有趣的排序题,类似acm 求大神解决!! 解决方案 排序就可以了http://zhidao.baidu.com/question/433177615.html?fr=iks&word=%C3%BF%B8%F6%D3%CE%CF%B7%D5%DF%B1%BB%B7%D6%C5%E4%B5%BD%D2%BB%D7%E9%B7%C7%B8%BA%D5%FB%CA%FD%2C%D3%CE%CF%B7%D5%DF%BF%C9%D2%D4%BD%AB%D5%E2%D0%A9%CA%FD%C5%

UVa 701 The Archeologists' Dilemma: 数学及枚举

701 - The Archeologists' Dilemma Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=642 An archeologist seeking proof of the presence of extraterrestrials i

UVa 131 The Psychic Poker Player:枚举&模拟好题

131 - The Psychic Poker Player Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=67 In 5-card draw poker, a player is dealt a hand of five cards (which may

uva 11039 - Building designing

点击打开链接uva 11039 思路:贪心(排序+枚举) 分析: 1 题目要求按照题目给定的数据求能够建立最高几层的楼房 2 题目要求上层的大小要比下层小,并且两层之间的颜色要交替的出现.很明显,我们只要按照size进行排序,然后枚举即可. 代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int M

iOS - Swift Enum 枚举

前言 枚举声明的类型是囊括可能状态的有限集,且可以具有附加值.通过内嵌(nesting),方法(method),关联值(associated values) 和模式匹配(pattern matching) 枚举可以分层次地定义任何有组织的数据. 和 switch 语句类似,Swift 中的枚举乍看之下更像是 C 语言中枚举的进阶版本,即允许你定义一种类型,用于表示普通事情中某种用例.不过深入挖掘之后,凭借 Swift 背后特别的设计理念,相比较 C 语言枚举来说其在实际场景中的应用更为广泛.特别

UVa 10176 Ocean Deep !

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1117 思路和UVa 11344是一样的,只不过那题是10进制,这题是2进制. 完整代码: 01./*0.019s*/ 02. 03.#include<cstdio> 04. 05.int main() 06.{ 07. int mod; 08. c

最短路专题【完结】

第一题 hdu 1317 XYZZY 点击打开hdu 1317 思路: 1 题目的图是一个有向图,并且可能存在环.第一个点的能量值为100,边的权值利用能量大小,例如2点为-60,如果1->2那么value[1][2] = -602 题目明确指出如果是要win的话,那么必须是经过的每条边都要大于0.那么我们只要把那些经过松弛操作后的点大于0的入队即可,小于等于0的点肯定不会出现在最终的路径上.3 如果存在正环的话,那么就有能量值无限大,那么这个时候只要判断这个点能否到达n4 判断是否是有环还是五

算法系列(七) 爱因斯坦的思考题(上)

这是一个很有趣的逻辑推理题,传说是爱因斯坦提出来的,他宣称世界上只有2%的人能解出这个 题目,传说不一定属实,但是这个推理题还是很有意思的.题目是这样的,据说有五个不同颜色的房 间排成一排,每个房间里分别住着一个不同国籍的人,每个人都喝一种特定品牌的饮料,抽一种特定 品牌的烟,养一种宠物,没有任意两个人抽相同品牌的香烟,或喝相同品牌的饮料,或养相同的宠物 ,问题是谁在养鱼作为宠物?为了寻找答案,爱因斯坦给出了十五条线索: (1).英国人住在 红色的房子里: (2).瑞典人养狗作为宠物: (3).

sql连接查询中,where关键字的位置

最近一直在忙,也没有太多时间停留下来写博客.晚上遇到一个觉得很有趣的sql题,可能对初学者和我这种菜鸟会有帮助,所以决定分享给大家. 由于笔者天生笨拙,且思维不严谨,也实在不擅长写sql语句,高手请勿见笑,就请直接跳过本文吧. 背景就不多介绍了,先建表,插入测试数据吧.字段那些都有注释 --医生表 CREATE TABLE doctor ( id INT IDENTITY(1, 1) , --ID 自增长 docNumber NVARCHAR(50) NOT NULL , --医生编码 NAME