Is Derek lying?(HDU 6045)
来源:互联网 发布:卖家淘宝小二怎么联系 编辑:程序博客网 时间:2024/06/05 03:18
Is Derek lying?
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 103 Accepted Submission(s): 64
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
//***思路***:设2个人正确的题数相减的绝对值为X,那么2个人至少要有X题的答案是不一样的,不然就是在撒谎。设2个人正确的题数相加的绝对值为Y,从第一题开始判断,先尽量使他们2个都对(如果2个人答案一样,判他们两个这题都是对的,2个人答案不一样,判一个对,一个错,谁对谁错无所谓,算他们2个对的总题数就行),如果达到了Y,证明没说谎,因为可以判他们之后的题都是错的(总共有3个选项,两个人最多选2个,让没选的那个为正确答案即可),若达不到Y,就说明在说谎,因为尽量使他们都对都打不到要求。
#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <cstring>#include <algorithm>using namespace std;const int MAX = 80000 + 100;int n, x, y;char str1[MAX];char str2[MAX];int main(){int T;scanf("%d", &T);while (T--){scanf("%d%d%d", &n, &x, &y);scanf("%s", str1);scanf("%s", str2);int ans = 0;int jia, jian;int sum = 0;jia = x + y;jian = abs(x - y);for (int i = 0; i < n; i++){if (str1[i] != str2[i]){ans++;if (ans == jian)break;}}if (ans < jian){printf("Lying\n");continue;}for (int i = 0; i < n; i++){if (str1[i] == str2[i])sum += 2;if (str1[i] != str2[i])sum++;if (sum == jia)break;}if (sum < jia){printf("Lying\n");continue;}elseprintf("Not lying\n");}return 0;}
阅读全文
0 0
- 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--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?
- (数学)HDU 6045 Is Derek lying?
- HDU 6045 Is Derek lying? 水题
- HDU 6045 Is Derek lying?【思维】
- hdu 6054-Is Derek lying?
- BZOJ 1066: [SCOI2007]蜥蜴 网络流题解
- UVa 725 DIVISION 除法
- 用js实现图片连播和联级菜单的实现
- 理解Object.defineProperty的作用
- 扩展欧几里得算法
- Is Derek lying?(HDU 6045)
- android jni
- 【Java编程】面向对象--继承、封装
- 递归汉诺塔问题
- (一)activity的生命周期分析
- Redis事务介绍
- 戴尔将在中国推出哪些SaaS服务?
- 面试经典冒泡排序java版
- MySQL 5.7 学习:功能性能的提升