Strategic Game
http://acm.hdu.edu.cn/showproblem.php?pid=1054
题意:保卫城市,给一棵树,让求放几个士兵,可以看到所有的树的节点;
题解:
最小点覆盖数
二分匹配vecter建图,最大匹配的值除以2就是答案;
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=1500+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int mp[N][N];
int col[N];
bool vis[N];
char str;
struct node{};
vector<int>G[N];
bool dfs(int u){for(int i=0,j=G[u].size();i<j;i++){int v=G[u][i];if(!vis[v]){vis[v]=1;if(col[v]==-1||dfs(col[v])){col[v]=u;return 1;}}}return 0;
}
int maxmatch(){int res=0;for(int i=0;i<n;i++){memset(vis,0,sizeof(vis));if(dfs(i))res++;}return res;
}
void init(){memset(mp,0,sizeof(mp));memset(col,-1,sizeof(col));for(int i=0;i<n;i++)G[i].clear();ans=0;
}
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);while(~scanf("%d",&n)){//scanf("%d%d",&n,&m);init();for(int i=1;i<=n;i++){scanf("%d:(%d)",&u,&k);for(int j=1;j<=k;j++){scanf("%d",&v);//mp[u][v]=1;//mp[v][u]=1;G[u].push_back(v);G[v].push_back(u);}}cout<<maxmatch()/2<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Strategic Game相关推荐
- HDU——1054 Strategic Game
Strategic Game Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Strategic game(树的最小点覆盖)
Strategic game 题意: 一个树,在一个节点放兵,周围的边就被守护,守护所有的边,问最少放多少兵 题解: 这种问题又称树的最小点覆盖 dp[x][1]以x为根的子树全被看住且在x上放置士兵 ...
- 【POJ - 1463】Strategic game (树上最小点覆盖,树形dp)
题干: Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the ...
- UVA497 Strategic Defense Initiative【LIS+DP】
"Commander! Commander! Please wake up commander!" "- mmmph. What time is it?" ...
- Strategic game poj1463
1463 -- Strategic game 题目大意:树上有n个点,每个点都可以放一枚棋子,每枚棋子可以影响到监管相邻的格子,问要使每个格子都受监管,最少需要多少棋子 1<=n<=150 ...
- 【论】Strategic sourcing selection for bike-sharing rebalancing: An evolutionary game approach
Strategic sourcing selection for bike-sharing rebalancing: An evolutionary game approach 作者:Wei Gu , ...
- 转:Top 10 Strategic Technology Trends for 2019
未来5年,可能会带来颠覆式变化的技术,不懂,先了解. 趋势1,自动化一切(Trend NO.1 :Autonomous Things) 趋势2,增强分析(Trend NO.2:Augmented An ...
- 高德纳2019十大战略科技趋势 - Gartner Top 10 Strategic Technology Trends for 2019
来自Garnter发布<Top 10 Strategic Technology Trends for 2019>,本文仅翻译部分内容,有兴趣的同学可以自行阅读.翻译可能不准确,欢迎指正. ...
- cambridge ifm strategic roadmapping takecontrol in times of uncerntainty
- HDU 1054 Strategic Game 最小点覆盖
最小点覆盖概念:选取最小的点数覆盖二分图中的所有边. 最小点覆盖 = 最大匹配数. 证明:首先假设我们求的最大匹配数为m,那么最小点覆盖必然 >= m,因为仅仅是这m条边就至少需要m个点.然后 ...
最新文章
- oracle往mysql数据同步存储过程_Oracle数据库之间数据同步
- 华为vrrp默认优先级_华为的VRRP怎么配置
- 17.QT-事件处理分析、事件过滤器、拖放事件
- auth复习和BBS项目的登录(1)
- ik分词和jieba分词哪个好_Pubseg:一种单双字串的BiLSTM中文分词工具
- Docker 入门尝鲜
- background部分总结
- 剑指前端(前端入门笔记系列)——Date对象
- 在NVME SSD上安装WIN7
- Java二分排序算法简易版(原创)
- 【mfc】解决鼠标钩子被占用焦点后不响应的问题
- 面经 - 计算机网络知识点
- Mybatis注解用法
- 嵌入式Linux系统优化的那些事儿
- 【小猿說】以小刀会“的成败论当今创业成败
- 《Ogre一步一步学开发》 一、Ogre源码编译与安装,从源代码开始构建Ogre图文教程(Ogre 1.12.1 Source + VS2019 + Windows10)
- “趣工厂”获得数百万元天使轮融资,梅鹤资本领投...
- java 数组 distinct_去重是distinct还是group by?
- 微信小程序css篇----背景(Background)与颜色(Color)
- 补码和真值的对应关系
热门文章
- c++ cef 获取内容_敢达争锋对决NT敢达C装备增援活动进行中!
- python使用正则验证电子邮件_如何使用正则表达式验证电子邮件地址?
- linux生成驱动编译的头文件,嵌入式Linux字符设备驱动——5生成字符设备节点
- mac 上搭建gitlabel_在Mac OS X中用Docker部署GitLab
- android 许可协议,Android 基本控件的使用二(注册许可协议)(CheckBox)
- SQL比oracle卡,对比Oracle与SQL Server
- 计算机软件中os具有什么功能,[计算机软件及应用]OS第三章1.ppt
- linux7主机名设置,centos7主机名、网络设置
- 1151压力变送器型号_罗斯蒙特变送器的标准精度!
- mysql union all sum_[数据库]SQL Server UNION ALL 结果 SUM函数造成精度丢失