码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 6045 多校签到题目

时间:2017-07-28 15:42:17      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:分时   end   http   problem   bsp   amp   不同的   clu   else   

http://acm.hdu.edu.cn/showproblem.php?pid=6045

题解:遍历一遍,求出两个人答案中相同的个数,用wa表示。然后我从大的数入手,当wa的数都尽可能在两个人答案的相同部分时,另一个人的答案中对的个数最小;当wa的数尽可能在两者答案不同的部分的时候,另一个人的答案对的个数最多。

ac代码:

#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
int main()
{
    cin.sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n,x,y;
        cin>>n>>x>>y;
        string a;
        string b;
        cin>>a;
        cin>>b;
        int ret=0;
        for(int i=0;i<n;i++)
        {
            if(a[i] == b[i] ) ret++;
        }
        int same=ret;
        int nosame=n-ret;
        int maxx=max(x,y);
        int minn=min(x,y);
        int wa=n-maxx;
        int l,r;
        if(same < wa) l=0;
        else l=same-wa;
        r=same+wa;
        if(l<=minn && minn <=r) cout<<"Not lying"<<endl;
        else cout<<"Lying"<<endl;
    }
    return 0;
}

 

hdu 6045 多校签到题目

标签:分时   end   http   problem   bsp   amp   不同的   clu   else   

原文地址:http://www.cnblogs.com/z1141000271/p/7250277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!