SDNUOJ 1247.A.网瘾少年周老灰(二分图最大匹配数)

比赛心态不太好,运气也不好,好多题真的浪费了就,感觉很难受,尤其第一题,比赛的时候只有第一题没有看,比完赛之后听说是二分图,当时难受的不行,以后一定要自己看完,很基础的二分图最大匹配数,直接套匈牙利算法模板就行啊啊啊啊啊啊啊

真的对不起队友,现在感觉很心酸,不要心寒,加油啊两位老哥!

Description

If you have played Hearthstone, you will figure out this problem easily.

Zhoulaohui is a shut-in so he play Hearthstone everyday. But on the deadline, if he do not study, he would not pass the final exam. So he decides to make out a water problem. He developed a simple Hearthstone and played well. Meanwhile he seemed to have some kind of compulsive disorder that he wants to wipe out all opponents and do not want his entourages to die.

One entourage or opponent has his health point and attack. If A fell on B, A’s health point will minus B’s attack and B’s health point will minus A’s attack. If someone’s health point is not greater than zero, his life will not exist. And one Zhoulaohui’s entourage only can fell on one opponent.

Now the number of Zhoulaohui’s entourages is equal to his opponents, he wants to know whether he can do it. Can you help him?

Input

the first line is the number of test cases T. (T<=100)

for each test case, first line will be an integer N. (1<=N<=100)

Following N lines, each line consists of 2 integers, Zhoulaohui’s entourage’s health point X and attack Y. (1<=X,Y<=100)

Then follow N lines, each line consists of 2 integers, Zhoulaohui’s opponent’s health point X and attack Y. (1<=X,Y<=100)

Output

If you think Zhoulaohui can achieve his goal, output “Sorry about that!”(without quotes).

Otherwise, output “Tell you a joke~”(without quotes).

Sample Input

134 45 56 61 12 23 3

Sample Output

Sorry about that!

Source

Unknown
题目要求,给定己方和敌人的生命值及战斗力,问是否可以完全击败敌方,简直就是再标准不过的“找对象”了,就是利用map数组记录可以击败的情况,利用二分图find函数一个一个挪出位置即可,简直模板中的模板题,很懊悔,有种马后炮的感觉

代码

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
int n;
struct node
{
    int gong1;//己方
    int xue1;
    int gong2;//敌方
    int xue2;
}e[105];
bool mapp[105][105];//将可以击败的情况记录下来
bool vis[105];
int enemy[105];//记录敌人匹配情况
bool find(int x)//利用递归找对象挪位置
{
    for(int i = 1; i <= n; i ++)
    {
        if(mapp[x][i] && ! vis[i])
        {
            vis[i] = 1;
            if(! enemy[i] || find(enemy[i]))
            {
                enemy[i] = x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t --)
    {
        memset(mapp, 0, sizeof(mapp));
        memset(enemy, 0, sizeof(enemy));
        scanf("%d",&n);
        for(int i = 1; i <= n; i ++)
            scanf("%d%d",&e[i].xue1, &e[i].gong1);
        for(int i = 1; i <= n; i ++)
            scanf("%d%d",&e[i].xue2, &e[i].gong2);
        for(int i = 1; i <= n; i ++)//遍历建立map数组
            for(int j = 1; j <= n; j ++)
        {
            if(e[i].xue1 > e[j].gong2 && e[i].gong1 >= e[j].xue2)
                mapp[i][j] = 1;
        }
        int ans = 0;
        for(int i = 1; i <= n; i ++)//寻找是否可以匹配
        {
            memset(vis, 0, sizeof(vis));
           if(find(i)) ans ++;
        }
        if(ans == n)printf("Sorry about that!\n");
        else printf("Tell you a joke~\n");
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值