Is Derek lying?

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

题目链接:点击打开链接

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 1point.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 Alfiawill 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

题意:D和A是好朋友,同时参加考试比赛,比赛完后,系统会告诉D他们俩的总得分情况,D比较顽皮,他有时不会向A汇报正确的得分情况, 做对一题得一分,告诉你有多少道题,以及D告诉A他和A的总分,然后分别给出D和A的答案,问你D是否对A撒谎了。
分析:假设一个人的答案全部正确为n,c是他们一样答案的个数,那么他们的的总得分一定不大于n+c,他们得分差一定不大于n-c。
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
char s1[300010],s2[300010];
int main()
{int t;scanf("%d",&t);while(t--){int a,b,n;scanf("%d %d %d",&n,&a,&b);scanf("%s",s1);scanf("%s",s2);int c=0;for(int i=0;i<n;i++){if(s1[i]==s2[i]) c++;//c是记录他们答案相同的个数}if(a+b<=n+c&&abs(a-b)<=n-c){printf("Not lying\n");}else{printf("Lying\n");}}return 0;
}

HDOJ 6045-Is Derek lying?相关推荐

  1. 2017 Multi-University Training Contest - Team 2——HDU6045HDU6047HDU6055

    讲一下这场多校赛里面比较简单的三个题 HDU6045  Is Derek lying? 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6045 题意:有 ...

  2. 并查集 HDOJ 1232 畅通工程

    题目传送门 1 /* 2 并查集(Union-Find)裸题 3 并查集三个函数:初始化Init,寻找根节点Find,连通Union 4 考察:连通边数问题 5 */ 6 #include <c ...

  3. 【HDOJ 3652】B-number

    [HDOJ 3652]B-number 给一整数n 找<=n的整数中能被13整除且含有13的 数位dp 记忆化! . 一入记忆化深似海. ..再也不想用递推了...发现真的非常好想 仅仅要保证满 ...

  4. 【HDOJ】4343 Interval query

    最大不相交集合的数量. 思路是dp[i][j]表示已经有i个不相交集合下一个不相交集合的最右边界. 离散化后,通过贪心解. 1 /* 4343 */ 2 #include <iostream&g ...

  5. 【HDOJ】4579 Random Walk

    1. 题目描述 一个人沿着一条长度为n个链行走,给出了每秒钟由i到j的概率($i,j \in [1,n]$).求从1开始走到n个时间的期望. 2. 基本思路 显然是个DP.公式推导也相当容易.不妨设$ ...

  6. AC自动机 HDOJ 5384 Danganronpa

    题目传送门 1 /* 2 题意:多个文本串,多个模式串在每个文本串出现的次数 3 AC自动机:这就是一道模板题,杭电有道类似的题目 4 */ 5 /************************** ...

  7. 构造 HDOJ 5400 Arithmetic Sequence

    题目传送门 题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j) 构造:用c1[i], c2[i] ...

  8. Kruskal HDOJ 1233 还是畅通工程

    题目传送门 1 /* 2 最小生成树之kruskal算法--并查集(数据结构)实现 3 建立一个结构体,记录两点和它们的距离,依照距离升序排序 4 不连通就累加距离,即为最小生成树的长度 5 */ 6 ...

  9. HDOJ 5373 The shortest problem 【数论】

    HDOJ 5373 The shortest problem [数论] 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5373 题目给一个初始数据和重复 ...

  10. AC解 - Phone List(HDOJ#1671) 前缀树的一个应用

    原题:http://acm.hdu.edu.cn/showproblem.php?pid=1671 Time Limit: 3000/1000 MS (Java/Others)    Memory L ...

最新文章

  1. 果蝇大脑研究能够改进计算机相似性搜索算法
  2. mysql 的connect 设置 无法点next_技术分享 | MySQL 使用 MariaDB 审计插件
  3. Java获取当前线程的名字以及为线程命名
  4. JS 中判断一个对象是否为数组对象?
  5. 【AI视野·今日CV 计算机视觉论文速览 第179期】Tue, 25 Feb 2020
  6. 微信红包发放接口服务器签名失败,微信现金红包接口开发注意的事项
  7. HDU 5273 Dylans loves sequence【 树状数组 】
  8. 矩阵卷积运算的具体过程,很简单
  9. 【日常计算机问题】装系统的烧录的U盘恢复方法
  10. 使用itext7统计PDF文件中的字数
  11. Ti c64x 优化基本策略
  12. php 批量导入表格,织梦dedecms批量导入excel表文章内容插件
  13. 程序员每天自动填写周报日报工时脚本完整脚本(附源码)
  14. Linux常用命令(压缩解压命令)
  15. 腾讯云后端面试15问(6年工作经验)
  16. Codevs 4246 奶牛的身高
  17. php+Sphinx分词中间件的认识和基础使用(亲测)
  18. webp怎么转png?图片webp格式怎么转换?
  19. 【表白程序】盛开的玫瑰代码
  20. GSAP,专业的Web动画库

热门文章

  1. 如何学会计算机基础,学会这4点,你就能快速掌握电脑基本操作,摆脱新手的标签...
  2. IT 如何把骨干留住
  3. [SDIO] SD card 初始化及常用命令解析(附波形,uboot代码)
  4. 怎么将多张图片打印在一张A4纸上?
  5. python数字的表示
  6. Easy3D配置、安装教程(补充教程)
  7. 20190406-楞次定律、洛伦兹力与安培力、切割磁感线过程中的能量关系
  8. 想学明白PostgreSQL,得先捋一捋体系架构
  9. 解读华为的流程与 IT 管理部门
  10. 车辆管理系统无法连接服务器,智能通道人员车辆管理软件常见问题