#include<bits/stdc++.h>
#define B bitset<105>
using namespace std;
typedef long long ll ;
const int N = ;
B G[N] ;
ll a[N] ;
typedef struct Node {
B mask;
ll val;
Node() {}
Node( B b,ll v):mask(b),val(v){}
bool operator < (const Node & rhs )const {
return val > rhs.val ;
}
}Node ;
int main()
{
int n,k;
while(~scanf("%d%d",&n,&k)){
for(int i=;i<=n;i++){
scanf("%lld",&a[i]);
}
for(int i=;i<=n;i++){
G[i].reset();
for(int j=,x;j<=n;j++){
scanf("%1d",&x);
G[i][j] = x ;
}
}
priority_queue < Node > Q ;
B tmp ;
tmp.reset();
Q.push( Node(tmp,) );
while( !Q.empty() ){
Node cur = Q.top() ;
Q.pop();
if( !(--k) ){
return *printf("%lld\n",cur.val );
}
int pos = ;
for(int i=;i<=n;i++){
if(cur.mask[i]){
pos = i+ ;
}
}
for(int i=pos;i<=n;i++){
if( ( G[i] & cur.mask ) == cur.mask ){
cur.mask[i] = ;
Q.push( Node(cur.mask,cur.val +a[i]) );
cur.mask[i] = ;
}
}
}
puts("-1");
}
return ;
}

【bitset】Kth Minimum Clique的更多相关文章

  1. Kth Minimum Clique

    Kth Minimum Clique 题目描述 Given a vertex-weighted graph with N vertices, find out the K-th minimum wei ...

  2. 牛客竞赛第二场D Kth Minimum Clique 贪心+bitmap

    Kth Minimum Clique 题意 给出n(n<100)个点的邻接表,和n个点的权值,求第k大的团(完全子图) 分析 n很小,并且好像没有什么算法和这个有关系,所以可以往暴力枚举的方向想 ...

  3. 【POJ2104】【HDU2665】K-th Number 主席树

    [POJ2104][HDU2665]K-th Number Description You are working for Macrohard company in data structures d ...

  4. 【leetcode】963. Minimum Area Rectangle II

    题目如下: Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from ...

  5. 【LeetCode】452. Minimum Number of Arrows to Burst Balloons 解题报告(Python)

    [LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https ...

  6. 【题解】kth异或和/魔改版线性基

    [题解]魔改版线性基 魔改版线性基解决此类问题. 联系线性空间的性质,我们直接可以构造出这样的基: \[ 100000 \\ 010000 \\ 000010 \\ 000001 \] 使得每个基的最 ...

  7. 牛客网多校训练第二场D Kth Minimum Clique

    链接:https://ac.nowcoder.com/acm/contest/882/D来源:牛客网 Given a vertex-weighted graph with N vertices, fi ...

  8. 【LeetCode】Find Minimum in Rotated Sorted Array 解题报告

    今天看到LeetCode OJ题目下方多了"Show Tags"功能.我觉着挺好,方便刚開始学习的人分类练习.同一时候也是解题时的思路提示. [题目] Suppose a sort ...

  9. 【leetcode】712. Minimum ASCII Delete Sum for Two Strings

    题目如下: 解题思路:本题和[leetcode]583. Delete Operation for Two Strings 类似,区别在于word1[i] != word2[j]的时候,是删除word ...

随机推荐

  1. flex的圣杯布局记录 (flex : 0 0 80px)

  2. sublime的一些记录

    { "keys": ["tab"], "command": "reindent", "context" ...

  3. 6.4hadoop idea本地运行器测试

    1.1  本地运行器进行本地测试 写一个MapReduce驱动程序,执行job,实现tool接口,所以可以通过hadoop的命令行去设置为本地运行模式.实现tool的run函数,在run函数中创建jo ...

  4. [题解] [SDOI2015] 序列统计

    题面 题解 设 \(f[i][j]\) 代表长度为 \(i\) 的序列, 乘积模 \(m\) 为 \(j\) 的序列有多少个 转移方程如下 \[ f[i + j][C] = \sum_{A*B\equ ...

  5. Git LFS的使用

    Git LFS的使用 Git LFS 是 Github 开发的一个 Git 的扩展,用于实现 Git 对大文件的支持 使用目的 在游戏开发过程中,设计资源占用了很大一部分空间. 像png,psd等文件 ...

  6. 动态连通性问题——算法union-find

    问题定义:问题的输入是一列整数对,其中每个整数都表示一个某种类型的对象,一对整数p,q可以被理解为"p和q是相连的".我们假设“相连”是一种对等的关系. 这也意味着它具有: 1.自 ...

  7. idea 使用maven 下载源码包

    方式1:全量下载源码包 方式二:下载单个源码包 随便找个源码可以看到文件上有download (标识下载源码包) choose sources表示选择那个版本的源码包

  8. Mysql mysqldumpslow命令详解

    mysqldumpslow命令 /path/mysqldumpslow -s c -t 10 /database/mysql/slow-log 这会输出记录次数最多的10条SQL语句. 其中: -s, ...

  9. Python 今天抽空学习了@Property

    1.@Property有啥用 1) @property使方法像属性一样调用 @property可以把一个实例方法变成其同名属性,以支持.号访问,它亦可标记设置限制,加以规范 2) @property成 ...

  10. linux下怎么用ssh连接另一台linux服务器

    linux系统大家都知道是服务器版本一般都没有图像界面,通过字符界面操作.用ssh远程方式远程,如果要从一台linux远程到另外一台系统应该怎么操作呢本经验咗嚛以cenots7为例演示   方法/步骤 ...