CodeForces - 157D

别再猜了!用这款百元PD协议分析仪,5分钟定位Type-C充电不兼容的元凶 本文详细介绍了如何使用百元PD协议分析仪快速定位Type-C充电兼容性问题。通过5步实战流程,包括硬件准备、报文解析、波形诊断、私有协议分析及经验总结,帮助工程师高效解决充电不兼容的调试难题,显著提升工作效率。 阅读详情

As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: “Which one committed the crime?”. Suspect number i answered either “The crime was committed by suspect number ai”, or “Suspect number ai didn’t commit the crime”. Also, the suspect could say so about himself (ai = i).

Sherlock Holmes understood for sure that exactly m answers were the truth and all other answers were a lie. Now help him understand this: which suspect lied and which one told the truth?

Input
The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ n) — the total number of suspects and the number of suspects who told the truth. Next n lines contain the suspects’ answers. The i-th line contains either “+ai” (without the quotes), if the suspect number i says that the crime was committed by suspect number ai, or “-ai” (without the quotes), if the suspect number i says that the suspect number ai didn’t commit the crime (ai is an integer, 1 ≤ ai ≤ n).

It is guaranteed that at least one suspect exists, such that if he committed the crime, then exactly m people told the truth.

Output
Print n lines. Line number i should contain “Truth” if suspect number i has told the truth for sure. Print “Lie” if the suspect number i lied for sure and print “Not defined” if he could lie and could tell the truth, too, depending on who committed the crime.

Example
Input
1 1
+1
Output
Truth
Input
3 2
-1
-2
-3
Output
Not defined
Not defined
Not defined
Input
4 1
+2
-3
+4
-1
Output
Lie
Not defined
Lie
Not defined
Note
The first sample has the single person and he confesses to the crime, and Sherlock Holmes knows that one person is telling the truth. That means that this person is telling the truth.

In the second sample there are three suspects and each one denies his guilt. Sherlock Holmes knows that only two of them are telling the truth. Any one of them can be the criminal, so we don’t know for any of them, whether this person is telling the truth or not.

In the third sample the second and the fourth suspect defend the first and the third one. But only one is telling the truth, thus, the first or the third one is the criminal. Both of them can be criminals, so the second and the fourth one can either be lying or telling the truth. The first and the third one are lying for sure as they are blaming the second and the fourth one.

首先判断每个人是逃犯的情况符不符合m个人说实话
然后判断合适的情况有多少
判断一个人是不是逃犯只要判断他被人说是逃犯和不说他是逃犯的人和等于m就可以了,因为如果他是逃犯那么这些人都没说谎。
然后通过可能发生的的事情的数量判断每个人说没说谎
如果一个人说另一个人是逃犯而这个人不可能是逃犯那么就是说谎
如果一个人说另一个人是逃犯而这个人确实可能是逃犯那么这个人说的话就不被确定
如果一个人说另一个人是逃犯而可能的事实只有一种那么他却说的就是实话而这个人是对的
如果一个人说其他人不是逃犯而这个人可能是逃犯那么他说的话就是不确定的
如果一个人说另一个人不是逃犯而这个人不可能是逃犯那么他说的就是对的
如果一个人说另一个人不是逃犯而这个人可能是逃犯并且事实唯一那么他就说了谎那么个人确实是逃犯

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int tu[100001], ky[100001], bky[100001], dui[100001],zgky=0,zgbky=0;
int main()
{
    int n, m;
    cin >> n >> m;
    for (int a = 1; a <= n; a++)
    {
        scanf("%d", &tu[a]);
        if (tu[a] < 0)bky[-tu[a]]++,zgbky++;
        else ky[tu[a]]++, zgky++;
    }
    int kn = 0;
    for (int a = 1; a <= n; a++)
    {
        if (ky[a] + zgbky - bky[a] == m)
        {
            kn++;
            dui[a] = 1;
        }
    }
    for (int a = 1; a <= n; a++)
    {
        if (tu[a] > 0)
        {
            if (!dui[tu[a]])printf("Lie\n");
            else if (kn > 1)printf("Not defined\n");
            else printf("Truth\n");
        }
        else
        {
            if(!dui[-tu[a]])printf("Truth\n");
            else if (kn > 1)printf("Not defined\n");
            else printf("Lie\n");
        }
    }
}
Educational Codeforces Round 157 (Rated for Div. 2)D. XOR Construction 【代码】Educational Codeforces Round 157 (Rated for Div. 2)D. XOR Construction。 阅读详情

相关推荐

GitLab社区版vs企业版:本地部署性能对比与选型建议(含实测数据)

本文深入对比GitLab社区版(CE)与企业版(EE)在本地部署中的性能差异与功能特性,提供实测数据与选型建议。测试显示EE版在并发克隆、CI流水线启动等场景性能提升显著,尤其适合需要高级安全合规与CI/CD功能的团队。文章还包含硬件配置指南与成本效益分析,帮助技术决策者做出明智选择。

weixin_28828243的博客 299

CodeForces 156B Suspects(枚举)

B. Suspects time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As Sherlock Holmes was investigating a crime, he identifiednsu...

weixin_30843605的博客 176

生物信息学投稿避坑指南:如何根据影响因子和审稿速度选择最适合的期刊

本文为生物信息学研究者提供全面的期刊投稿策略,重点解析影响因子、审稿速度等关键指标,帮助选择最适合的期刊。涵盖算法开发类和应用型研究的投稿路径,分析不同出版社特点及开放获取的利弊,并提供投稿全流程优化建议,助力高效发表研究成果。

weixin_42652674的博客 384

CodeForces解题报告——1

Codeforces解题报告 ——序号1 题目1A: Theatre Square 题意: 在一个n*m的矩形块里面用,a*a 的正方形瓷砖铺满它,问最少个数? 只需要计算边界上,最多需要的数量,然后相乘就好! 代码: int main() { #ifdef LOCAL //freopen("in.txt", "r", stdin); //freo

gscsdlz的博客 705

【阿里云大模型高级工程师ACP习题集】2.9 大模型应用生产实践(下篇)

【摘要】这是我精心整理出对应的习题集,里面足足有 30 道题目,从基础概念到深度拓展,全方位覆盖章节重点、难点。不管你是想检验自己的学习成果,还是想针对薄弱环节进行强化训练,它都能完美适配!

davidkorhenn的博客 2255

mysql笔记:23. 在Mac上安装与卸载MySQL

MySQL对Mac电脑的适配十分强大,再加上Mac本身就是Unix操作系统演化而来的,所以在Mac上安装MySQL的方式有多种。常见的方法有如下三种:DMG、brew、TAR。介绍这些方法前,我们先了解下MySQL安装文件的下载。

斌斌(Java) 2253

Codeforces 156B 想法

Suspects time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As Sherlock Holmes was investigating a crime, he i

black_miracle的博客 463

华大HC32F460串口超时中断+DMA收发实战:从STM32迁移的避坑指南

本文为从STM32迁移至华大HC32F460的开发者提供了串口DMA收发的实战避坑指南。核心在于理解HC32F460以串口接收超时中断替代空闲中断的机制,并调整DMA配置策略:DMA应设置为由串口接收事件持续触发搬运,超时中断仅负责通知和重置DMA,从而实现高效可靠的数据收发。

weixin_29175469的博客 116

codeforces 156B Suspects 暴力

Suspectstime limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output As Sherlock Holmes was investigating a crime, he identified n suspects. He knows fo

enamor_AC的博客 955

【图像去噪】基于偏微分方程(PDE)实现图像去噪附matlab代码

在工程应用中,图像信息通过数字图像系统进行处理、存储和传输等加工变换时,由于不可避免地受到噪声干扰,使得原始图像信息产生偏差和失真,给图像的后续处理带来不便,进而影响人们对图像视觉特性的认知程度。因此,为了改善图像的质量效果,提高人们对图像视觉特性的认知度,对图像噪声进行有效去除,降低噪声对图像信息的干扰是很有必要的。近年来,基于偏微分方程( partial differential equation,PDE) ​的图像去噪方法在计算机视觉和图像处理等技术领域得到了广泛的重视,因为它在平滑噪声的同时,能够很

qq_59747472的博客 862

准备生日礼物

摘要: 题目要求统计某月份需要准备的员工生日礼物数量。输入包括目标月份、员工姓名列表和对应的生日列表(格式为Year/Month/Day)。需处理重复员工(以最后一次录入为准),统计该月生日的员工人数。示例1中5月有3名员工生日,输出3;示例2中10月有6名,输出6。解题关键在于使用哈希表去重(以员工姓名为键),拆分生日字符串提取月份进行匹配。代码实现(C++/Java/Python)均遵循以下步骤:读取输入、哈希去重、解析月份并统计目标月份人数。时间复杂度为O(n),空间复杂度O(n)。

面试高手的博客 306

codeforces 157D 模拟

/*题意:福尔摩斯正在处理一件案子。此时已经抓捕了n个嫌疑人,里面只可能有一个是真正的犯人。福尔摩斯正在审问这些嫌疑人。 每个嫌疑人的回答只有两种,一种表明他说编号为i的嫌疑人不是犯人,用-i表示;另一种表明他说编号为i的嫌疑人是犯人, 用+i表示。聪明的福尔摩斯已经知道了其中有m个人说的是真话。要求那些人说的是真话,那些人说的是假话。*/ /*思路:我们先假设某个人是嫌疑犯,然后统计真话的个数

yellowjianokok的博客 538

C#上位机多PLC多协议开发思路:10年老工控师拆解实战方案,避坑90%的问题(附代码框架)

是否连接成功数据地址(如“DB1.DBW0”“D100”“4x0001”)

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 957

Educational Codeforces Round 157 (A--D)视频详解

Educational Codeforces Round 157 (A--D)视频详解

Turing_Sheep的博客 502

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Educational Codeforces Round 157 (Rated for Div. 2)D题

原cf网页链接。

rc85qbte的博客 95

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

Educational Codeforces Round 157 (Rated for Div. 2)(D)拆位

当中某一位上的数为0,然后遍历求出整个b数组中该位上1的数量,看是否与之前算出来1的数量相符,如果相符则代表该位可以为0,如果不相符则代表该位上的数字为1。思路:异或问题想到拆位处理,由于b中包含了0~n-1当中的所有数,换句话说也就是b数组当中每一位上1的数量是已知的。中每一位上的数确定下来,整个b数组就能确定下来了。遍历所有位,可以先假设。1、b中包含了从0 ~ n - 1 中的所有数,也就是说b是一个排列。求出来以后,b数组当中其余的数都是固定下来的。

weixin_61825750的博客 653

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Educational Codeforces Round 157 (Rated for Div. 2) D. XOR Construction (思维题)

给定长为n-1(n

小衣同学的博客 347

Educational Codeforces Round 157 (Rated for Div. 2)C,D

C题要求寻找所有符合要求的拼串,那么一眼暴力就是枚举所有拼串组合的可能性,但这样必然会超时。我们不妨从每一个数作为左边或者作为右边来入手,当某一个数作为左边的时候那么这个拼后的串的中间点就去这个数里面去寻找,可能是在某处也可能是这一整个数。那么这样的去寻找就可以将所有符合要求的组合找到。那么我们选定一个数的某个部分作为拼后串的左半部分后,就可以确定右半部分需要总和是多少以及多长。在这里事先将每一个数的长度和总和求出来,那么在寻找的时候可以直接hash去寻找个数,加快速度。

m0_60288082的博客 302

Codeforces Round #157 (Div. 2)D(数位DP+组合数)

D. Little Elephant and Elections time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There have recently been e

cq_phqg 879

Educational Codeforces Round 157 (Rated for Div. 2)

观察题意发现一个字符串有用的部分只有它的长度和总和,用一个数组来存储就好了。关键在于重复的问题了,我们发现这种做法只能与长度小于等于自身的字符串拼接。那么可以发现,一个字符串如果和长度不等于自身的字符串拼接是不会产生重复的。先找可以接在它右边的,由于要求长度是偶数,接在它后面的长度可以为。个数,分为两组,使得每组的相邻两数之差的绝对值相加之和最好。长度为偶数且字符串前一半的数位和等于后一半的数位和。要减去二,(自己和自己拼接的情况),最后加上。和长度相同的拼接则会有重复,这里可以用。,再计算数位和就好了。

2301_79248730的博客 1170

Educational Codeforces Round 157 (Rated for Div. 2) C D(二维map,位运算)

从前往后遍历字符串数组,当前遍历到的位置 j 与所有之前的位置 i (i < j) 的字符串拼接,对于每个 i 和 j,都有 (i,j) 和 (j,i) 两种拼接状态。可以根据位来处理,对于每位,等号左边该位为1的个数记为 target ,0 ~ n-1 所有数该位为1的个数记为 cnt。令 s[i] 为 a[1] ~ a[i] 的前缀异或,将已知条件变形可得 s[i] = b[1] ^ b[i + 1]。当 target = cnt 时,b[1]为0;又因为一定存在b[1],故否则 b[1]为1。

weixin_62701031的博客 449

Codeforces Round #157 (Div. 2) D. Little Elephant and Elections(数位DP+枚举)

数位DP部分,不是很难。DP[i][j]前i位j个幸运数的个数。枚举写的有点搓。。。 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 #define LL __int64 5 #define MOD 1000000007 6 int dp[21][21...

weixin_30390075的博客 140

CodeForces #157(258A|258B|258C|258D|258E)|数位DP|搜索|线段树

258A - Little Elephanh and Bits 小象有一个二进制表示的整数a。现在它要删掉一个二进制位,使这个新整数最大。 输入 输出 样例 input 101 output 11 input 110010 output 11010 题解 显然删去尽量高位的0答案就最大,当然没有0的话随便删个1就好了。 代码 258B

とある黄鱼のOIブログ 711

Trace CodeForces - 157B

asdf 给出N个同心圆 最外面的环形为红色。然后每个环形蓝红相间。求红色部分的面积. #include #include #include #include using namespace std; int cmp(int a,int b){ return a>b;} int main(void) { int a[105],i; int n; double square=0; ci

qq_35003691的博客 389

Codeforces Round #157 (Div. 1)C(因数分解+二分+组合数)

C. Little Elephant and LCM time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves the LC

cq_phqg 923

Codeforces Round #157(完整)

转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove  259A:每一行,wbwbwbwb,bwbwbwbw这两种情况是合法的 259B:SB了半天,题目只说了对角线是未知的,随意瞎搞吧,不知道什么好办法  258A:被cha一次,注意全为1的情况,就是从高

窝不是爱酱,喵~~~~ 1993
上一篇: CodeForces - 703D
下一篇: CodeForces - 165C
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值