zoukankan      html  css  js  c++  java
  • 2017ACM暑期多校联合训练

    题目链接

    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

    题意:
    有n道题,每道题做对得一分,做错不得分,有一个人说“第一个人得X分,第二个人得Y分”,有这两个人关于这n道题得答案,判断一下这句话能否正确。

    思路:
    这答案中会有num数目得答案两个人是完全相同得,至于这num道题究竟对几道我们不需要考虑,(x-y)得绝对值得到的是两个人做对的题目得差,这个值肯定要小于(n-num)这个值,还要满足条件就是说两个人除去共同作对的题目,其余作对的题目的和也是要小于等于(n-num)这个值。

    #include<iostream>
    #include<stdio.h>
    #include<string>
    #include<cmath>
    using namespace std;
    const int N=80009;
    int n,num,score1,score2;
    char ch1[N];
    char ch2[N];
    int main()
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            num=0;
            scanf("%d%d%d",&n,&score1,&score2);
            scanf("%s",ch1);
            scanf("%s",ch2);
            int flag=0;
            for(int i=0; i<n; i++)
            {
                if(ch1[i]==ch2[i])
                    num++;
            }
            int Min=min(score1,score2);
            Min=min(num,Min);
            if((abs(score1-score2)<=n-num)&&(score1+score2-2*Min<=n-num))
                printf("Not lying
    ");
            else
                printf("Lying
    ");
    
        }
        return 0;
    }
    
  • 相关阅读:
    AODV点点滴滴
    让控件的DropdownMenu或者PopupMenu弹出来
    如何让CoolBar控件的Bands在同一行上
    怎样在InstallShield的Basic MSI Project中用InstallScript添加路径
    VC调用Delphi制作的动态链接库如何互相传递字符串
    Delphi 中用 GetEnvironmentVariable 获取常用系统变量
    如何在工具栏或者其他的控件上显示其他控件的Hint
    企业信息开发平台(1)序
    对.Net 垃圾回收的C#编程相关方面(Finalize 和Dispose(bool disposing)和 Dispose())的一些理解体会(转)
    android上怎样让一个Service开机自动启动
  • 原文地址:https://www.cnblogs.com/cmmdc/p/7246746.html
Copyright © 2011-2022 走看看