HDU——1498 50 years, 50 colors
50 years, 50 colors
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2683 Accepted Submission(s): 1538
There will be a n*n matrix board on the ground, and each grid will have a color balloon in it.And the color of the ballon will be in the range of [1, 50].After the referee shouts "go!",you can begin to crash the balloons.Every time you can only choose one kind of balloon to crash, we define that the two balloons with the same color belong to the same kind.What's more, each time you can only choose a single row or column of balloon, and crash the balloons that with the color you had chosen. Of course, a lot of students are waiting to play this game, so we just give every student k times to crash the balloons.
Here comes the problem: which kind of balloon is impossible to be all crashed by a student in k times.
1
2 1
1 1
1 2
2 1
1 2
2 2
5 4
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
3 3
50 50 50
50 50 50
50 50 50
0 0
1
2
1 2 3 4 5
-1
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define N 110 using namespace std; bool vis[N],vist[N]; int n,k,sum,tot,ans[N],girl[N],a[N][N],map[N][N]; int read() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar();} return x*f; } int find(int x) { ;i<=n;i++) { if(!vis[i]&&map[x][i]) { vis[i]=true; ||find(girl[i])) {girl[i]=x; ;} } } ; } int col() { ; memset(girl,-,sizeof(girl)); ;i<=n;i++) { memset(vis,,sizeof(vis)); if(find(i)) s++; } return s; } void begin() { sum=,tot=; memset(a,,sizeof(a)); memset(ans,,sizeof(ans)); memset(vist,,sizeof(vist)); } int main() { ) { n=read(),k=read(); &&k==) break; begin(); ;i<=n;i++) ;j<=n;j++) a[i][j]=read(); ;i<=n;i++) ;j<=n;j++) if(!vist[a[i][j]]) { vist[a[i][j]]=true; memset(map,,sizeof(map)); ;u<=n;u++) ;v<=n;v++) if(a[u][v]==a[i][j]) map[u][v]=; if(col()>k) ans[++sum]=a[i][j]; } ) {printf("-1\n"); continue;} sort(ans+,ans++sum); ;i<sum;i++) printf("%d ",ans[i]); printf("%d\n",ans[sum]); } ; }
HDU——1498 50 years, 50 colors的更多相关文章
- hdu 1498 50 years, 50 colors(二分匹配_匈牙利算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1498 50 years, 50 colors Time Limit: 2000/1000 MS (Ja ...
- HDU 1498 50 years, 50 colors(最小点覆盖,坑称号)
50 years, 50 colors Problem Description On Octorber 21st, HDU 50-year-celebration, 50-color balloons ...
- hdu 1498 50 years, 50 colors 最小点覆盖
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- 50 years, 50 colors
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Hdu 1498 二分匹配
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 1498(最小点覆盖集)
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU——T 1498 50 years, 50 colors
http://acm.hdu.edu.cn/showproblem.php?pid=1498 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
- 50 years, 50 colors HDU - 1498(最小点覆盖或者说最小顶点匹配)
On Octorber 21st, HDU 50-year-celebration, 50-color balloons floating around the campus, it's so nic ...
- HDU 1498:50 years, 50 colors(二分图匹配)
http://acm.hdu.edu.cn/showproblem.php?pid=1498 题意:给出一个 n*n 的矩阵,里面的数字代表一种颜色,每次能炸掉一排或者一列的相同颜色的气球,问有哪些颜 ...
随机推荐
- Maximum Subsequence Sum 最大子序列和的进击之路
本文解决最大子序列和问题,有两个题目组成,第二个题目比第一个要求多一些(其实就是要求输出子序列首尾元素). 01-复杂度1 最大子列和问题 (20分) 给定KK个整数组成的序列{ N1, N2 ...
- 微信小程序之多行文本省略号
最近在捣鼓小程序,期间遇到的问题,踩过的坑,也是在网上各种搜.这里也说下我解决的问题,方便大家. 在小程序首页显示文本列表的时候,为了美观,不希望把所有的文本都显示出来,希望是显示前几行(比如前3行, ...
- R in action读书笔记(13)第十章 功效分析
功效分析 功效分析可以帮助在给定置信度的情况下,判断检测到给定效应值时所需的样本量.反过来,它也可以帮助你在给定置信度水平情况下,计算在某样本量内能检测到给定效应值的概率.如果概率低得难以接受,修改或 ...
- linux下redis安装访问
下载编译安装 wget http://download.redis.io/releases/redis-3.0.1.tar.gz tar xvf redis-3.0.1.tar.gz mv redis ...
- MATLAB 中的randn函数
matlab函数 randn:产生正态分布的随机数或矩阵的函数 randn:产生均值为0,方差σ^2 = 1,标准差σ = 1的正态分布的随机数或矩阵的函数. 用法: Y = randn(n):返回一 ...
- PHP面向对象考察点
面向对象三大特性 封装 封装性就是把对象的属性和服务结合成一个独立的相同单位,并尽可能隐蔽对象的内部细节,包含两个含义: 把对象的全部属性和全部服务结合在一起,形成一个不可分割的独立单位(即对象). ...
- CAD参数绘制对齐标注(网页版)
主要用到函数说明: _DMxDrawX::DrawDimAligned 绘制一个对齐标注.详细说明如下: 参数 说明 DOUBLE dExtLine1PointX 第一条界线开始点X值 DOUBLE ...
- Laravel Homestead的安装和使用(照搬)
原文:https://blog.csdn.net/woqianduo/article/details/81091154/ 1.简介 1.1.Homestead是什么 Laravel Homestead ...
- 06Hibernate基本配置
Hibernate基本配置 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊先保存后修改
- vue 中slot 的具体用法
子组件 <template> <div class="slotcontent"> <ul> <!--<slot></sl ...