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

阅读: 评论:0

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

二分图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;
}

本文发布于:2024-01-27 17:05:36,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063463351550.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:网瘾   少年   周老灰
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23