裸二分图匹配

 /*--------------------------------------------------------------------------------------*/

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map> //debug function for a N*M array
#define debug_map(N,M,G) printf("\n");for(int i=0;i<(N);i++)\
{for(int j=;j<(M);j++){\
printf("%d",G[i][j]);}printf("\n");}
//debug function for int,float,double,etc.
#define debug_var(X) cout<<#X"="<<X<<endl;
#define LL long long
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
/*--------------------------------------------------------------------------------------*/
using namespace std; int N,M,T,t;
const int maxn = ;
vector <int> G[maxn];
int uN;
int Mx[maxn],My[maxn];
int dx[maxn],dy[maxn];
int dis;
bool used[maxn];
bool SearchP()
{
queue<int> Q;
dis = INF;
memset(dx,-,sizeof dx);
memset(dy,-,sizeof dy);
for(int i=;i<=uN;i++)
{
if(Mx[i] == -)
{
Q.push(i);
dx[i] = ;
}
}
while(!Q.empty())
{
int u = Q.front();
Q.pop();
if(dx[u] > dis) break;
int sz = G[u].size();
for(int i=;i<sz;i++)
{
int v = G[u][i];
if(dy[v] == -)
{
dy[v] = dx[u] + ;
if(My[v] == -) dis = dy[v];
else
{
dx[My[v]] = dy[v] + ;
Q.push(My[v]);
}
}
}
}
return dis != INF;
}
bool DFS(int u)
{
int sz = G[u].size();
for(int i=;i<sz;i++)
{
int v = G[u][i];
if(!used[v] && dy[v] == dx[u]+)
{
used[v] = true;
if(My[v] != - && dy[v] == dis) continue;
if(My[v] == - || DFS(My[v]))
{
My[v] = u;
Mx[u] = v;
return true;
}
}
}
return false;
} int MaxMatch()
{
int res = ;
memset(Mx,-,sizeof Mx);
memset(My,-,sizeof My);
while(SearchP())
{
memset(used,false,sizeof used);
for(int i=;i<=uN;i++) if(Mx[i] == - && DFS(i))
res++;
}
return res/;
} typedef pair<int,int> point;
vector <point> gst;
int v[maxn]; int main()
{
scanf("%d",&T);
int cas = ;
while(T--)
{
scanf("%d%d",&t,&N);
for(int i=;i<maxn;i++) G[i].clear(); gst.clear();
for(int i=,x,y,s;i<=N;i++)
{
scanf("%d%d%d",&x,&y,&s);
gst.push_back(make_pair(x,y));
v[i] = s;
}
scanf("%d",&M);
uN = N+M;
for(int i=,x,y;i<=M;i++)
{
scanf("%d%d",&x,&y);
for(int g=;g<gst.size();g++)
{
if((x-gst[g].first)*(x-gst[g].first)+(y-gst[g].second)*(y-gst[g].second) <= t*v[g+]*t*v[g+])
{
G[g+].push_back(i+N);
G[i+N].push_back(g+);
//printf("link:[%d,%d]\n",g+1,i+N);
}
}
}
printf("Scenario #%d:\n%d\n\n",++cas,MaxMatch());
}
}

HDU2389-Rain on your Parade-二分图匹配-ISAP的更多相关文章

  1. hdu2389 Rain on your Parade 二分图匹配--HK算法

    You’re giving a party in the garden of your villa by the sea. The party is a huge success, and every ...

  2. HDU2389 Rain on your Parade —— 二分图最大匹配 HK算法

    题目链接:https://vjudge.net/problem/HDU-2389 Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)  ...

  3. hdu-2389.rain on your parade(二分匹配HK算法)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  4. Hdu 3289 Rain on your Parade (二分图匹配 Hopcroft-Karp)

    题目链接: Hdu 3289 Rain on your Parade 题目描述: 有n个客人,m把雨伞,在t秒之后将会下雨,给出每个客人的坐标和每秒行走的距离,以及雨伞的位置,问t秒后最多有几个客人可 ...

  5. Hdu2389 Rain on your Parade (HK二分图最大匹配)

    Rain on your Parade Problem Description You’re giving a party in the garden of your villa by the sea ...

  6. BZOJ.3546.[ONTAK2010]Life of the Party(二分图匹配 ISAP)

    题目链接 题意:求哪些点一定在最大匹配中. 这儿写过,再写一遍吧. 求哪些点不一定在最大匹配中.首先求一遍最大匹配,未匹配点当然不一定在最大匹配中. 设一个未匹配点为A,如果存在边A-B,且存在匹配边 ...

  7. HDU2389:Rain on your Parade(二分图最大匹配+HK算法)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  8. HDU 2389 Rain on your Parade / HUST 1164 4 Rain on your Parade(二分图的最大匹配)

    HDU 2389 Rain on your Parade / HUST 1164 4 Rain on your Parade(二分图的最大匹配) Description You're giving a ...

  9. HDU 2389 Rain on your Parade(二分匹配,Hopcroft-Carp算法)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  10. HDU2389(二分图匹配Hopcroft-Carp算法)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

随机推荐

  1. 15、安全工程师要阅读的书籍 - IT软件人员书籍系列文章

    信息安全工程师是一个比较新兴的角色.在2016年今年的下半年软考就将安全工程师纳入了考试科目,说明国家对安全工程师的需求还是不错的.安全工程师包括硬件和软件两块内容吧.这里描述的安全工程师主要是针对软 ...

  2. android项目中配置NDK自动编译生成so文件

    1 下载ndk开发包   2 在android 项目中配置编译器(以HelloJni项目为例)  2.1 创建builer  (a)Project->Properties->Builder ...

  3. SQL Server连接SQL Server、SQL Server连接ORACLE 链接服务器

    夸数据库访问有很多种方式,其中部分用作接口访问,这里要介绍的是MSSQL访问另一台MSSQL,MSSQL访问ORACLE,其它暂不介绍. 1.MSSQL访问另一台MSSQL: a.展开服务器对象--& ...

  4. asp.net mvc 之旅—— 第二站 窥探Controller下的各种Result

    平时我们在Action中编码的时候,我们都知道所有的Action返回值类型都是ActionResult,并且我们的返回值也是各种奇葩,比如:Json(),Content(), View()等等...当 ...

  5. 高效coder,筹备开源框架toutou.escort.js

    背景:JavaScript在工作中运用的非常广泛,作为一门弱类型语言,在使用JavaScript的时候,很多事情需要coder manual的去完成,这无疑增加了coder的工作量. 扩展:在这样的背 ...

  6. W3School-CSS测验

    The only way to survive was to enjoy the good moments and not dwell too much on the bad. 生活,就应该享受美好的 ...

  7. CentOS 7最小化安装后找不到‘ifconfig’命令——修复小提示

    如果你不知道在哪里可以找到ifconfig命令,请按照以下简单的步骤来找到它.首先,让我们找出哪个包提供了ifconfig命令.要完成这项任务,输入以下命令: [root@jrserver app_f ...

  8. mysql 动态新建以及删除分区表

    因为项目需要,最近研究了一下在mysql数据库下如何动态新建以及删除分区表.如果全部借助存储过程的话,新建以及删除分区表在逻辑上比较死板.不灵活,而且还容易出错.因此,我新建了一个数据表table_f ...

  9. Jmeter默认报告优化

    一.本文目的: 之前写了两篇文章搭建持续集成接口测试平台(Jenkins+Ant+Jmeter)和ANT批量执行Jmeter脚本,功能实现上都没有什么问题,但是最后生成的报告有一点小问题,虽然不影响使 ...

  10. Type mismatch: cannot convert from MainFragment to Fragment 报错

    源码: FragmentTransaction mFragmentTranscation = getSupportFragmentManager().beginTransaction(); Fragm ...