二分图1247.A.网瘾少年周老灰

123hanyanwei
Toggle Dropdown
1247.A.网瘾少年周老灰
Time Limit: 1000 MS Memory Limit: 131072 KB
Total Submission(s): 13 Accepted Submission(s): 7
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
1
3
4 4
5 5
6 6
1 1
2 2
3 3
Sample Output
Sorry about that!

//二分图
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn = 100;
struct cha
{
    int s;//生命值
    int g;//攻击力
}a[maxn],b[maxn];//我方,敌方
int line[maxn][maxn];
int girl[maxn],used[maxn];
int k,m,n;
//核心
bool found(int x)
{
    for(int i=1;i<=n;i++){
        if(line[x][i]&&!used[i]){
            used[i]=1;//标记随从干掉的敌人
            if(girl[i]==0||found(girl[i])){
            //如果没有人打过敌人i,或者敌人i可以被让出来,这里递归found的作用是让上一次的随从换一个敌人
                girl[i]=x;
                return 1;
            }
        }
    }
    return 0;

}
int main()
{
    int T;
    cin >> T;
    while(T--){
        cin >> n ;//人数
        memset(line,0,sizeof(line));
        memset(girl,0,sizeof(girl));
        for(int i=0;i<n;i++){
            cin >> a[i].s >> a[i].g;
        }
        for(int i=0;i<n;i++){
            cin >> b[i].s >> b[i].g;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(a[i].s>b[j].g&&a[i].g>=b[j].s)
                    line[i][j]=1;//我能干掉的敌人标记为一
            }
        }
        int sum=0;
        for(int i=0;i<n;i++){     // 遍历每一个随从
            memset(used,0,sizeof(used));
            if(found(i)) sum++;
        }

        if(sum==n) cout << "Sorry about that!" << endl;
        else cout << "Tell you a joke~" << endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值