2 shunfurh shunfurh 于 2017.09.16 17:17 提问

This Sentence is False

The court of King Xeon 2.4 is plagued with intrigue and conspiracy. A document recently discovered by the King's Secret Service is thought to be part of some mischievous scheme. The document contains simply a set of sentences which state the truth or falsehood of each other. Sentences have the form "Sentence X is true/false" where X identifies one sentence in the set. The King's Secret Service suspects the sentences in fact refer to another, yet uncovered, document.

While they try to establish the origin and purpose of the document, the King ordered you to find whether the set of sentences it contains is consistent, that is, if there is a valid truth assignment for the sentences. If the set is consistent, the King wants you to determine the maximum number of sentences which can be made true in a valid truth assignment for the document.

Input

The input file contains several instances of documents. Each document starts with a line containing a single integer, N, which indicates the number of sentences in the document (1 <= N <= 1000). The following N lines contain each a sentence. Sentences are numbered sequentially, in the order they appear in the input (the first is sentence 1, the second is sentence 2, and so on). Each sentence has the form "Sentence X is true." or "Sentence X is false.", where 1 <= X <= N. The value N = 0 indicates the end of input.

Output

For each document in the input your program should output one line. If the document is consistent, your program should print the maximum number of sentences in a valid truth assignment for the document. Otherwise your program should print the word 'Inconsistent'.

Sample Input

1
Sentence 1 is false.
1
Sentence 1 is true.
5
Sentence 2 is false.
Sentence 1 is false.
Sentence 3 is true.
Sentence 3 is true.
Sentence 4 is false.
0

Sample Output

Inconsistent
1
3

1个回答

devmiao
devmiao   Ds   Rxr 2017.09.30 21:14
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
2018_2_14_This Sentence is False_并查集_关系
作为根的,flag是0,别的根据这一点确定The court of King Xeon 2.4 is plagued with intrigue and conspiracy. A document recently discovered by the King's Secret Service is thought to be part of some mischievous sc...
Jieba分词包(一)——解析主函数cut
Jieba分词包——解析的Python源代码
[ZOJ1518][POJ1291] This Sentence is False
ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1518POJ: http://poj.org/problem?id=1291题目大意:有n个句子,编号为1..n,为Sentence XXX is
POJ 1291: This Sentence is False
题目链接:http://poj.org/problem?id=1291 题意: 给出n句话, 形如“第x句话是错误的”或“第x句话是正确的”。 判断是否有合法结果。 若有,计算至多有多少句话是正确的。 算法: 典型的并查集。 对于每个节点,维护与父节点的距离d[x], 同一并查集内, 相对距离为偶数的节点共真假。 每处理一条关系, 若这两句话不在一个
十分钟快速上手结巴分词
一.特点1、支持三种分词模式    精确模式,试图将句子最精确的切开;    全模式,把句子中所有的可以成词的词语都扫描出来,速度非常快,但是不能解决歧义;    搜索引擎模式,在精确模式的基础上,对长词再次切分,提高召回率,适合用于搜索引擎分词。2、支持繁体分词3、支持自定义词典4、MIT授权协议二.安装说明代码对Python 2/3 均兼容全自动安装:easy_install jieba 或者...
POJ1291 This Sentence is False (并查集 || 哈希)
本文出自:http://blog.csdn.net/svitter 写在之前: 最近感觉做了不少的并查集的题目。发现A说B说的对,谁说假话谁说真话这种游戏,基本全是并查集。做下记录,防止以后忘记。 题意: 题目给出n句话,编号从1开始。每一句话都是类似:Sentence $num is true/false 这种形式。 最后输出真话最多的情况的真话个数。 输入输出分析:
POJ 1291 This Sentence is False 笔记
判断文件中有多少真话。
sentence是的用法
Python语法支持。result是列表,sentence是列表,sentence[:]是列表切片意思是取其所有项 convert返回的是列表,所以可以赋值给两个变量
Exercise 41:学会阐述面向对象
原文链接:http://learnpythonthehardway.org/book/ex41.html
英语写作之——Topic Sentence 的写法
摘要 本文主要讲述如何写Topic Sentence. 1. 根本原则:观点明确 Topic Sentence一定要体现出你的观点,所谓的观点即可以定义为思考的产物!不说没有主题的官话(没营养的废话),因为那会让人觉得作者很傻;也不要说事实,因为那不是经过思考的谈不上观点;另外,最好不要用疑问句,反问句,因为观点直接一点更好,而且英文写作追求直接高效的语言应用(比如:写作上,一针见血