博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2017多校联合训练2—HDU6054--Is Derek lying?(思维题)
阅读量:4966 次
发布时间:2019-06-12

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

Is Derek lying?

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 612    Accepted Submission(s): 353

Problem Description

Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This summer holiday,they both participate in the summer camp of Borussia Dortmund.During the summer camp,there will be fan tests at intervals.The test consists of N choice questions and each question is followed by three choices marked “A” “B” and “C”.Each question has only one correct answer and each question is worth 1 point.It means that if your answer for this question is right,you can get 1 point.The total score of a person is the sum of marks for all questions.When the test is over,the computer will tell Derek the total score of him and Alfia.Then Alfia will ask Derek the total score of her and he will tell her: “My total score is X,your total score is Y.”But Derek is naughty,sometimes he may lie to her. Here give you the answer that Derek and Alfia made,you should judge whether Derek is lying.If there exists a set of standard answer satisfy the total score that Derek said,you can consider he is not lying,otherwise he is lying.

Input

The first line consists of an integer T,represents the number of test cases.

For each test case,there will be three lines.
The first line consists of three integers N,X,Y,the meaning is mentioned above.
The second line consists of N characters,each character is “A” “B” or “C”,which represents the answer of Derek for each question.
The third line consists of N characters,the same form as the second line,which represents the answer of Alfia for each question.
Data Range:1≤N≤80000,0≤X,Y≤N,∑Ti=1N≤300000

Output

For each test case,the output will be only a line.

Please print “Lying” if you can make sure that Derek is lying,otherwise please print “Not lying”.

Sample Input

 

2 3 1 3 AAA ABC 5 5 0 ABCBC ACBCB

Sample Output

 

Not lying Lying

Source

Recommend

liuyiding   |   We have carefully selected several similar problems for you: 

题意:

有n道题,每个题有ABC三个选项,有一个答案是正确的。每道题做对得一分,做错不得分,给定命题:“第一个人得X分,第二个人得Y分”,然后有这两个人关于这n道题得答案,判断一下这个答案序列能否成立

思路:

考虑到只有两种情况下这是不正确的:

1.x+y超过了给定答案能够提供的最大分数,这是x+y的上界。注意,x+y是没有下界的(可以答对0道)

2.x与y的差值过大。例如,答案全为相同的,x与y的差值为1。处理这种情况时,找到差值的上界(差值只能从不相同的答案得到),比较即可。

x+y>2*n-cntd

abs(x-y)>cntd

代码:

1 /*  2 * @FileName: D:\代码与算法\2017训练比赛\多校2\1001.cpp  3 * @Author: Pic  4 * @Date:   2017-07-28 10:28:50  5 * @Last Modified time: 2017-07-28 12:12:41  6 */  7   8 #include
9 using namespace std; 10 const int MAXN=80000+30; 11 int a[MAXN],b[MAXN]; 12 int main(){ 13 int t; 14 scanf("%d",&t); 15 while(t--){ 16 int n,x,y; 17 char ch; 18 scanf("%d%d%d",&n,&x,&y); 19 getchar(); 20 for(int i=0;i
cntd) flag=0; 40 if(x+y>2*n-cntd) flag=0; // 41 if(flag){ 42 printf("Not lying\n"); 43 } 44 else{ 45 printf("Lying\n"); 46 } 47 } 48 return 0; 49 }
View Code

转载于:https://www.cnblogs.com/liuzhanshan/p/7249358.html

你可能感兴趣的文章
两台电脑间的消息传输
查看>>
Linux 标准 I/O 库
查看>>
.net Tuple特性
查看>>
Java基础常见英语词汇
查看>>
iOS并发编程笔记【转】
查看>>
08号团队-团队任务5:项目总结会
查看>>
SQL2005 删除空白行null
查看>>
mysql备份与恢复
查看>>
混沌分形之迭代函数系统(IFS)
查看>>
边框圆角Css
查看>>
使用Busybox制作根文件系统
查看>>
jpg图片在IE6、IE7和IE8下不显示解决办法
查看>>
delphi之模糊找图
查看>>
Javascript模块化编程的写法
查看>>
oracle 使用job定时自动重置sequence
查看>>
在项目中加入其他样式
查看>>
OMAPL138学习----DSPLINK DEMO解析之SCALE
查看>>
restframework CBV试图的4种方式
查看>>
大图居中,以1920px为例
查看>>
[C陷阱和缺陷] 第7章 可移植性缺陷
查看>>