HDU 6045 Is Derek lying? 思维

  题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6045

  题目大意: 给定两个长度相等的字符串, 给出一组比分, 问这组比分是否可能。

  解题思路: 统计两个字符串字符的相同数和不同数, 两者相差小于等于不同数, 两者相加减去一倍的相同数<=n

  代码: 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

const int N=80004;
char xx[N],yy[N];
int main()
{
    int t,n,x,y;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&x,&y);
        scanf("%s",xx);
        scanf("%s",yy);
        int ans=0;
        for(int i=0;i<n;i++){
            if(xx[i]==yy[i])ans++;
        }
        if(x+y<=(n+ans)&&abs(y-x)<=(n-ans)){
            printf("Not lying\n");
        }
        else printf("Lying\n");
    }
    return 0;
}
View Code

  思考: 这题应该是一道水题的, 但是我进入了思想的误区, 一个范围这道题就出来是对的, 但是我......哎, 没法说, 题见得还是太少了

posted on 2017-07-30 09:48  FriskyPuppy  阅读(156)  评论(0编辑  收藏  举报

导航