【补题】多校联合训练第二场

第二场

1001 Is Derek lying?

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

思路:首先,我们统计出Derek和Alfia答案相同的题目数量k1和答案不同的题目数量k2. 对于两人答案相同的题目,共有以下两种情况:

a.两人都对

b.两人都错

对于两人答案不同的题目,共有以下三种情况:

c.Derek对Alfia错

d.Alfia对Derek错

e.两人都错

于是我们可以列出一些方程:

k1+k2=n

a+b=k1

c+d+e=k2

a+c=x

a+d=y

又a,b,c,d,e均为非负整数,且满足a,b<=k1;c,d,e<=k2,将a,b,d,e全部用c替换后需要同时满足以下四个条件:

0<=c<=k2

x-y<=c<=k2+x-y

(x-y)/2<=c<=(k2+x-y)/2

x-k1<=c<=x

我们只需要判断这四段区间存不存在公共的整数点,如果存在,则说明Derek没有说谎;如果不存在,则说明Derek在说谎。

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<algorithm>
 5 #include<cmath>
 6 #include<vector>
 7 #include<set>
 8 #include<string>
 9 #include<sstream>
10 #include<cctype>
11 #include<map>
12 #include<stack>
13 #include<queue>
14 using namespace std;
15 #define INF 0x3f3f3f3f
16
17 const int maxn =  80000 + 10;
18 char a[maxn], b[maxn];
19
20 int main()
21 {
22 //    freopen("input.txt", "r", stdin);
23 //    freopen("output.txt", "w", stdout);
24     int T, n, x, y;
25     scanf("%d", &T);
26     while(T--)
27     {
28         int p = 0, q = 0;
29         scanf("%d%d%d", &n, &x, &y);
30         scanf("%s", a);
31         scanf("%s", b);
32         for(int i = 0; i < n; i++)
33         {
34             if(a[i] == b[i])    p++;
35             else    q++;
36         }
37         if(fabs(x - y) <= q && x + y <= 2 * p + q)
38             printf("Not lying\n");
39         else    printf("Lying\n");
40     }
41     return 0;
42 }

第二场就做了一题,第三场除了一题签到题其他题都不会做,被九题十题的高中生草虐,我好菜啊.jpg

今天是暑假第一次这么早起,加油加油,继续刷题。

时间: 2024-07-30 10:07:29

【补题】多校联合训练第二场的相关文章

2014多校联合训练第一场(组队训练)

这是我.potaty.lmz第二次训练,毕竟经验不足,加上水平不够,导致我们各种被碾压. A - Couple doubi: 这道题是道比较水的数论.但我们都没想出来要怎么做.后来是potaty提议打个表看看,然后lmz打出表后发现了规律.我还没细看,待研究后再补全. D - Task: 这道题一看就知道是个贪心(现在只要是有deadline的题我都觉得是贪心了).虽然想出来了,但还是不会严格证明为什么只要取满足task的且y最小(y相等时x最小)的machine就行了. 我的做法是把所有mac

【补题】多校联合训练第一场

1001  Add More Zero Problem Description There is a youngster known for amateur propositions concerning several mathematical hard problems.Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to s

2015多校联合训练第一场Tricks Device(hdu5294)

题意:给一个无向图,给起点s,终点t,求最少拆掉几条边使得s到不了t,最多拆几条边使得s能到t 思路: 先跑一边最短路,记录最短路中最短的边数,总边数-最短边数就是第二个答案 第一个答案就是在最短路里面求最小割,也就是求最大流,然后根据最短路在建个新图,权为1,跑一边网络流 模板题,以后就用这套模板了 #include <iostream> #include <cstdio> #include <cstring> #include <queue> #incl

2015多校联合训练第一场Assignment(hdu5289)三种解法

题目大意:给出一个数列,问其中存在多少连续子序列,子序列的最大值-最小值 #include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cmath> using namespace std; int maxsum[100000][30]; int minsum[100000][30]; int a[100000]; int n,k; v

2018年四校联合周赛-第二场 B.异或和问题(二维树状数组)

异或和问题 TimeLimit:1000MS  MemoryLimit:256MB 64-bit integer IO format:%I64d Problem Description 现在有一个n行n列的矩阵.初始状态下,矩阵里的所有值都为0.行的编码是从1到n,列的编码也同样是从1到n. ai,?j.是在第i行第j列的数.子矩阵(x0, y0, x1, y1)是由ai,?j. (x0?≤?i?≤?x1, y0?≤?j?≤?y1)组成的矩阵. 现在需要进行下列的两个操作:       1.查询

2015年多校联合训练第一场OO’s Sequence(hdu5288)

题意:给定一个长度为n的序列,规定f(l,r)是对于l,r范围内的某个数字a[i],都不能找到一个对应的j使得a[i]%a[j]=0,那么l,r内有多少个i,f(l,r)就是几.问所有f(l,r)的总和是多少. 公式中给出的区间,也就是所有存在的区间. 思路:直接枚举每一个数字,对于这个数字,如果这个数字是合法的i,那么向左能扩展的最大长度是多少,向右能扩展的最大长度是多少,那么i为合法的情况就是左长度*右长度(包含i且i是合法的区间总数). 统计左长度可以判断a[i]的约数是否在前面出现过-因

HDU 5371 (2015多校联合训练赛第七场1003)Hotaru&#39;s problem(manacher+二分/枚举)

HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分相同,第一部分与第二部分对称. 现在给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法,求出以第i个点为中心的回文串长度,记录到数组p中 要满足题目所要求的内容,需要使得两个相邻的回文串,共享中间的一部分,也就是说,左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也是一样. 因为我们已经记录下来以

HDU 5371 (2015多校联合训练赛第七场1003)Hotaru&amp;#39;s problem(manacher+二分/枚举)

pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法.求出以第i个点为中心的回文串长度.记录到数组p中 要满足题目所要求的内容.须要使得两个相邻的回文串,共享中间的一部分,也就是说.左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也

2014多校联合-第五场

1001:Inversion 模版题,求逆序数对.有多少逆序数对,就可以剪掉多少. 1003:Least common multiple 对于每一个子集,lcm为2的a的最大值次方*3的b的最大值次方. 所以我们只需要求出以某个b为b的最大值的时候,a的最大值的分布情况即可. 我们先把b从小到大排序. 对于某一个b,我门只需要求出之前出现过的a比当前a小的数量为x: 那么就可知对于这些a的子集,为2^x个,并且,每个子集a的最大值都为当前a. 我么还需要求出对于大于当前a的a有多少个比a小的数,