比赛心态不太好,运气也不好,好多题真的浪费了就,感觉很难受,尤其第一题,比赛的时候只有第一题没有看,比完赛之后听说是二分图,当时难受的不行,以后一定要自己看完,很基础的二分图最大匹配数,直接套匈牙利算法模板就行啊啊啊啊啊啊啊
真的对不起队友,现在感觉很心酸,不要心寒,加油啊两位老哥!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
代码
#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;
}