hdu 5090 Game with Pearls (二分匹配)
来源:互联网 发布:中国联通淘宝旗舰店 编辑:程序博客网 时间:2024/06/05 05:50
///给你n个管子原先有些珍珠///对这些管子有两种操作 1:不加珍珠 2: 加k倍数数目的珍珠///如果能使管子里的珍珠为1.2.3.4....n Jerry赢///解法:二分匹配# include<stdio.h># include<algorithm># include <iostream># include<string.h>using namespace std;int map[110],pp[110][110],n,vis[110];int bfs(int x){ for(int i=1; i<=n; i++) //B组中的人来迎合匹配 { if(!vis[i]&&pp[x][i]) { vis[i]=1; if(!map[i]||bfs(map[i]))//b中i还没匹配或与之匹配的A组中的数(map[i])还能找到其他人匹配 { map[i]=x; return 1; } } } return 0;}int main(){ int t,i,a[110],k; while(~scanf("%d",&t)) { while(t--) { scanf("%d%d",&n,&k); memset(pp,0,sizeof(pp)); memset(map,0,sizeof(map)); for(i=0; i<n; i++) { scanf("%d",&a[i]); } for(i=0; i<n; i++) { int tt=a[i]; while(tt<=n&&a[i]<=n) { pp[a[i]][tt]=1;///每个管子可以匹配的容量 tt+=k; } } int count=0; for(i=0; i<n; i++) { memset(vis,0,sizeof(vis)); if(bfs(a[i])) count++; } // printf("%d\n",count); if(count==n) printf("Jerry\n"); else printf("Tom\n"); } } return 0;}
0 0
- 【二分匹配】 HDU 5090 Game with Pearls
- hdu 5090 Game with Pearls (二分匹配)
- Hdu 5090 Game with Pearls(二分匹配)
- HDU 5090 Game with Pearls(二分匹配)
- HDU 5090 Game with Pearls(二分匹配)
- HDU 5090--Game with Pearls【二分图最大匹配】
- HDU 5090 Game with Pearls【贪心||模拟||二分匹配】
- HDU ACM 5090 Game with Pearls->二分图最大匹配或?
- HDOJ 5090 Game with Pearls 二分图匹配
- hdoj 5090 Game with Pearls 【二分图最大匹配】
- hdu 5090 Game with Pearls(最大匹配)
- hdu 5090 Game with Pearls(最大匹配)
- hdu 5090 Game with Pearls
- hdu 5090 Game with Pearls
- HDU 5090 Game with Pearls
- HDU 5090 Game with Pearls
- HDU 5090 - Game with Pearls
- HDU-5090--Game with Pearls
- hdu 5093 Battle ships(最大流)
- 栈和队列
- HDU 5099 Comparison of Android versions(字符串)
- [LeetCode OJ]Populating Next Right Pointers in Each Node
- Android项目-高考作文功能简介(一)
- hdu 5090 Game with Pearls (二分匹配)
- MDCC 2014移动开发者大会 参展商活动的小礼品
- GitHub“最受欢迎的开源项目” TOP 50 android开源项目 直接拿来用
- python如何安装pip和easy_installer工具
- 寻路算法 A* (一)
- 去爬山恐感被体的干撒
- WIN7网络不能正常访问到windows2003服务器共享目录
- HDU 1506 Largest Rectangle in a Histogram
- C# 字段、属性、成员变量