裸二分图匹配

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

 #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. 从技术经理的角度算一算,如何可以多快好省的做个app

    [导读]前端时间,一篇“从产品经理的角度算一算,做个app需要多少钱”的文章在网上疯传,可见大家对互联网创业的热情!这次,从一名技术经理的角度再给大家分析一下,如何使用跨平台开发技术为你节省上百万的开 ...

  2. 《内容生产向视频过渡:Facebook收购QuickFire意欲何为?》有感

    1月9日消息,Facebook周四表示,已收购位于加州圣迭戈的QuickFire Networks. 一.解决视频传输问题 QuickFire是一家开发视频内容发布设备和转码处理软件的创业公司,其创办 ...

  3. Tomcat:云环境下的Tomcat设计思路——Tomcat的多实例安装

    Cloud现在是一个热门的技术,Tomcat是学习Java的人一般都会接触的Web服务器,如果在Cloud环境下使用Tomcat,又当如何呢?不可避免的,要安装多个Tomcat了,这里称之为Tomca ...

  4. MySQL基础学习(二) 常用SQL命令

    一. 1. select version();  查看数据库版本 2. select user(); 查看当前用户 3. select now(); 查看当前时间 4. show databases; ...

  5. 烂泥:【转】rsync命令参数详解

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. rsync安装完毕后,我们可以通过rsync –help查看rysnc命令的使用.如下: 有关rsync的命令格式,在此我们就不多介绍了.如果有想了解的 ...

  6. ICTCLAS中文分词库的使用

    ICTCLAS计算所中文分词(当前最好的汉语词法分析器)系统特点:准确度高(98.5%),性能优越(500KB/s分词速度),词性标注(POS tagging)且支持多种标注集,支持用户自定义词典,支 ...

  7. 异或的精彩应用 FIX_BTMAP_END

    源文件是arch/x86/include/asm/fixmap.henum fixed_addresses {#ifdef CONFIG_X86_32        FIX_HOLE,...    _ ...

  8. linux挂载windows上的共享文件夹

    假定win机d:/folder/share的共享名为 share , 有用户administrator ,密码123 在linux机上,把share挂到/mnt目录:mount -t cifs -o ...

  9. [转]ng-grid

    本文转自:http://angular-ui.github.io/ui-grid/ Getting Started Steps for getting started (example on righ ...

  10. java 26 - 8 网络编程之 TCP协议的练习

    TCP练习: 1.客户端键盘录入,服务器输出文本文件 客户端代码: public class ClientDemo { public static void main(String[] args) t ...