设为首页 加入收藏

TOP

HDU 1498 50 years, 50 colors (行列匹配+最小顶点覆盖)
2014-11-23 21:38:16 来源: 作者: 【 】 浏览:7
Tags:HDU 1498 years colors 行列 匹配 最小 顶点 覆盖
题意:每个格子有不同颜色的气球用不同数字表示,每次可选某一行
或某一列来戳气球。每个人有K次机会。求最后哪些气球不能在
k次机会内被戳破。将这些气球的编号按升序输出。
分析:行列匹配,每种颜色的气球都要判断,故dfs传参时加一个气球的
编号。
感想:1、开始以为要按照最大匹配数按升序排列,昨天wa了一下午,把我搞郁闷了。
今天重新看题,是要按照id来排序。
2、学习了vector的用法,以前都不会用。。。这个之后汇总了再。。。
代码:
#include  
#include  
#include  
#include  
#include  
using namespace std;  
  
struct node  
{  
    int id;  
    int cnt;  
}t[55];  
int g[110][110];  
int match[110];  
int vis[110];  
int n;  
vector myv;  
  
bool cmp(node a,node b)  
{  
    return a.cnt>b.cnt;  
}  
bool dfs(int u,int v)  
{  
    for(int i=0;ik)  
                myv.push_back(t[j].id);  
        }  
        sort(myv.begin(),myv.end());  
        if(flag)  
        {  
            for(i=0;i 
  

积累:
对vector中的元素排序:
头文件#include
vector arr;
//输入数据
sort(arr.begin(),arr.end());
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 3074 Sudoku (Dancing Links.. 下一篇UVALive 4329 Ping pong

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何从内核协议栈到 (2025-12-27 03:19:09)
·什么是网络协议?有哪 (2025-12-27 03:19:06)
·TCP/ IP协议有哪些 (2025-12-27 03:19:03)
·怎样用 Python 写一 (2025-12-27 02:49:19)
·如何学习python数据 (2025-12-27 02:49:16)