2017多校联合训练2—HDU6054--Is Derek lying?(思维题)
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
2017 Multi-University Training Contest - Team 2
Recommend
liuyiding | We have carefully selected several similar problems for you: 6055 6054 6053 6052 6051
题意:
有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<bits/stdc++.h>
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<n;i++){
21 scanf("%c",&ch);
22 a[i]=ch-'A';
23 }
24 getchar();
25 for(int i=0;i<n;i++){
26 scanf("%c",&ch);
27 b[i]=ch-'A';
28 }
29 int cnts=0,cntd=0;
30 for(int i=0;i<n;i++){
31 if(a[i]==b[i]){
32 cnts++;
33 }
34 else{
35 cntd++;
36 }
37 }
38 int flag=1;
39 if(abs(x-y)>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 }
2017多校联合训练2—HDU6054--Is Derek lying?(思维题)的更多相关文章
- 2017 ACM暑期多校联合训练 - Team 9 1008 HDU 6168 Numbers (模拟)
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk gen ...
- 2017 ACM暑期多校联合训练 - Team 5 1008 HDU 6092 Rikka with Subset (找规律)
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...
- 2017 ACM暑期多校联合训练 - Team 4 1007 HDU 6073 Matching In Multiplication (模拟)
题目链接 Problem Description In the mathematical discipline of graph theory, a bipartite graph is a grap ...
- 2017 ACM暑期多校联合训练 - Team 4 1012 HDU 6078 Wavel Sequence (模拟)
题目链接 Problem Description Have you ever seen the wave? It's a wonderful view of nature. Little Q is a ...
- 2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)
题目链接 Problem Description RXD is a good mathematician. One day he wants to calculate: ∑i=1nkμ2(i)×⌊nk ...
- NFLSOJ 1072 - 【2021 六校联合训练 NOIP #1】异或(FWT+插值)
题面传送门 一道非常不错的 FWT+插值的题 %%%%%%%%%%%% 还是那句话,反正非六校的看不到题对吧((( 方便起见在下文中设 \(n=2^d\). 首先很明显的一点是这题涉及两个维度:异或和 ...
- NFLSOJ 1060 - 【2021 六校联合训练 NOI #40】白玉楼今天的饭(子集 ln)
由于 NFLSOJ 题面上啥也没有就把题意贴这儿了( 没事儿,反正是上赛季的题,你们非六校学生看了就看了,况且看了你们也没地方交就是了 题意: 给你一张 \(n\) 个点 \(m\) 条边的图 \(G ...
- 2016多校联合训练4 F - Substring 后缀数组
Description ?? is practicing his program skill, and now he is given a string, he has to calculate th ...
- 2014 多校联合训练赛6 Fighting the Landlords
本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include< ...
随机推荐
- axios配置
import axios, { isCancel } from 'axios' import { md5 } from 'vux' import util from '@/libs/util' imp ...
- BZOJ2456-mode题解--一道有趣题
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=2456 瞎扯 这是今天考的模拟赛T2交互题的一个30分部分分,老师在讲题时提到了这题.考 ...
- java写webservice接口
有一个需求:要求根据设备mac和终端设备类型来查询设备库存状态. 接口协议是采用webservice协议,信息交互方式为xml格式信息 输入参数存放到XML各个节点下,并转为一个String,作为接口 ...
- 基于JWT的token身份认证方案(转)
https://www.cnblogs.com/xiangkejin/archive/2018/05/08/9011119.html 一.使用JSON Web Token的好处? 1.性能问题. JW ...
- Docker 备忘
C/S架构: 客户端发出命令给服务器端(内含守护进程),守护进程执行命令后将结果传回给客户端.(可以远程访问,可以本地访问) 容器内部操作: 可写层下面都是只读的,操作时需要什么文件会被复制到可写层, ...
- spring ioc aop 理解
OC,依赖倒置的意思,所谓依赖,从程序的角度看,就是比如A要调用B的方法,那么A就依赖于B,反正A要用到B,则A依赖于B.所谓倒置,你必须理解如果不倒置,会怎么着,因为A必须要有B,才可以调用B,如果 ...
- Java经典基础与高级面试36题和答案
1.”static”关键字是什么意思?Java中是否可以覆盖(override)一个private或者是static的方法? “static”关键字表明一个成员变量或者是成员方法可以在没有所属的类的实 ...
- Nginx作为静态资源web服务之缓存原理
Nginx作为静态资源web服务之缓存原理 大致理一下http浏览器缓存原理: 浏览器第一次请求服务器,此时浏览器肯定没有缓存,则直接调用服务器端,服务器在返回的信息的信息头中添加 ETag和Last ...
- raise与raise······from
在python中,如果想手动引发一个异常,我们一般都会使用raise # -*- coding:utf-8 -*- # @Author: WanMingZhu # @Date: 2019/10/22 ...
- pandas中的Series
我们使用pandas经常会用到其下面的一个类:Series,那么这个类都有哪些方法呢?另外Series和DataFrame都继承了NDFrame这个类,df.to_sql()这个方法其实就是NDFra ...