#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. jar包中的依赖jar版本冲突

    背景,项目中之前引入了一个 图片上传的jar <groupId>commons-fileupload</groupId> <artifactId>commons-f ...

  2. zabbix监控windows案例

    首先在zabbix官网下载zabbix软件包:https://www.zabbix.com/ 下载完成之后,将其解压到D盘 # 配置与安装,配置zabbix agent相关配置. 找到conf下的配置 ...

  3. ICEM—倾斜孔

    原视频下载:https://yunpan.cn/cS3UGMEscrYpL  访问密码 839b

  4. iOS开发 Error: CGImageProviderCreate: invalid image provider size

    一般可拉伸的图片(俗称点9图片)会放到images.xcassets目录里,然后对图片进行Slicing,但是当对一张图片进行slicing的left和right都是0的话,在iOS7.0上运行会出现 ...

  5. 【SVN】彻底 svn 服务器上的 删除某一个文件或文件夹

    参考: CSDN1:https://blog.csdn.net/u011729865/article/details/78764523 CSDN2:https://blog.csdn.net/wyyo ...

  6. 官网引用的axios,lodash文件在脚手架中如何使用?

    对于官网属性与侦听器模块,所引用的以下文件在脚手架中如何使用? <script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/ ...

  7. InsetDrawable

    表示把一个Drawable嵌入到另外一个Drawable的内部,并且在内部留一些间距, 类似与Drawable的padding属性,但padding表示的是Drawable的内容与Drawable本身 ...

  8. kotlin 类的委托

    fun main(arg: Array<String>) { val baseImpl = baseImpl() demo(baseImpl).printL() } interface b ...

  9. C之指针

    什么是指针 * 指针变量:用来存储某种数据在内存中的地址.* 世面上书籍一般把指针和指针变量的概念混在一起了.市面上的书籍说的指针指的就是指针变量 Ø *号的三种含义1. 两个数相乘int i =5; ...

  10. springboot之rabbitmq安装与实践

    环境:腾讯云centos7 注意:rabbitmq安装插件,可能会报错.本人是主机名的问题,所以修改了主机名. vim /etc/hosts vim /etc/hostname 修改这两个文件,并重启 ...