HDU-6045-Is Derek lying?
来源:互联网 发布:ubuntu版本查看命令 编辑:程序博客网 时间:2024/06/05 00:52
Is Derek lying?
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1598 Accepted Submission(s): 826
Problem Description
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 integersN ,X ,Y ,the meaning is mentioned above.
The second line consists ofN characters,each character is “A ” “B ” or “C ”,which represents the answer of Derek for each question.
The third line consists ofN 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
For each test case,there will be three lines.
The first line consists of three integers
The second line consists of
The third line consists of
Data Range:
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 ”.
Please print “
Sample Input
23 1 3AAAABC5 5 0ABCBCACBCB
Sample Output
Not lyingLying
解题代码
#include <iostream>#include <stdio.h>#include <math.h>using namespace std;char ch[80005];char sh[80005];int main(){ int T; scanf("%d",&T); while(T--) { int N,X,Y; scanf("%d%d%d",&N,&X,&Y); getchar(); scanf("%s",ch); getchar(); scanf("%s",sh); int count1=0; int sum=X+Y;//计算两个人最大可能得到的分数总和最低应该是X+Y int mul=fabs(X-Y);//两个人不同的答案最低应该有X-Y个 for(int i=0;i<N;i++) { if(ch[i]!=sh[i]) count1++; if(count1==mul) break; } if(count1<mul) { printf("Lying\n"); continue; } count1=0; for(int i=0;i<N;i++) { if(ch[i]==sh[i])//当两个人答案相同时都加分,当答案不同的时候随便一个加一分, count1+=2;//这样得到的才是两个得到的分数的总和的最大可能值 else count1+=1; if(count1==sum) break; } if(count1<sum) printf("Lying\n"); else printf("Not lying\n"); } return 0;}
阅读全文
0 0
- HDU 6045 Is Derek lying?
- hdu 6045 Is Derek lying?
- HDU 6045 Is Derek lying?
- hdu--6045 Is Derek Lying
- hdu 6045 Is Derek lying?
- HDU 6045 Is Derek lying?【】
- HDU 6045 Is Derek lying?
- HDU-6045-Is Derek lying?
- hdu 6045 Is Derek lying?
- Is Derek lying? HDU
- HDU 6045多校Is Derek lying?
- Is Derek lying?(HDU 6045)
- (数学)HDU 6045 Is Derek lying?
- HDU 6045 Is Derek lying?(思维)
- HDU 6045 Is Derek lying? 水题
- HDU 6045 Is Derek lying?【思维】
- HDU 6045 Is Derek lying?(水~)
- hdu 6054-Is Derek lying?
- Python编程之基本方法
- hydra暴力破解ssh密码
- jquery妙招去除html标记
- C#反射技术的简单操作(读取和设置类的属性)
- 五、迭代器--迭代器配接器
- HDU-6045-Is Derek lying?
- Parity check(大数取模)
- Java异常处理
- 初识editableGrid 控件
- 新零售核心是大数据驱动的线上线下融合
- 五、迭代器--迭代器辅助函数
- awk基本手册汇总
- 2017多校训练Contest2: 1006 Funny Function hdu6050
- memcached全面剖析–5. memcached的应用和兼容程序