【二分匹配】 HDU 5090 Game with Pearls
来源:互联网 发布:数据分析的具体流程 编辑:程序博客网 时间:2024/05/29 16:13
坑点:盒子的编号你还不知道的~
解题方法有很多种
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#define cler(arr, val) memset(arr, val, sizeof(arr))typedef long long LL;const int MAXN = 100200;const int MAXM = 6000010;const int INF = 0x3f3f3f3f;const int mod = 1000000007;int g[256][256],a[333];int gn,gm;int link[2566];bool used[2566];bool dfs(int u){ for(int v=1; v<=gm; v++) if(g[u][v]&&!used[v]) { used[v]=true; if(link[v]==-1||dfs(link[v])) { link[v]=u; return true; } } return false;}int getmax(){ int sum=0; cler(link,-1); for(int i=1; i<=gn; i++) { cler(used,false); if(dfs(i)) sum++; } return sum;}int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout);#endif int t,n,m; cin>>t; while(t--) { cler(g,0); cin>>n>>m; for(int i=1; i<=n; i++) scanf("%d",&a[i]); gn=gm=n; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if((j-a[i])%m==0&&j>=a[i]) g[i][j]=1; } } int ans=getmax(); if(ans==n) puts("Jerry"); else puts("Tom"); } 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
- android应用生命周期
- jdk安装与环境变量配置
- cocos2dx中setPosition的坐标位置
- hdu 5099 简单模拟(比较型号)
- MySQL-5.6.13免安装版配置方法
- 【二分匹配】 HDU 5090 Game with Pearls
- 《Effective C++ 》学习笔记——条款04
- X11 window program basic
- 【DP】 HDU 5092 Seam Carving
- 作为学生,我是怎么半年赚到人生第一个三十万的
- poj 2528
- 【二分匹配】 HDU 5093 Battle ships 经典二分题
- Java虚拟机类加载原理
- HDU 1800