#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. UVALive 3716 DNA Regions ——(扫描法)

    乍一看这个问题似乎是很复杂,但其实很好解决. 先处理出每个点到原点的距离和到x正半轴的角度(从x正半轴逆时针旋转的角度).然后以后者进行排序. 枚举每一个点到圆心的距离,作为半径,并找出其他到圆心距离 ...

  2. C语言问答九问

    C语言问题观: 一.环境搭建问题:linux,(可以是w10下linux子系统):vim(notepad++),gcc编译器,gdb调试器,make自动编译工具,ddd分析工具和valgrind分析工 ...

  3. ICEM—两孔圆柱

    ​原视频下载地址: https://pan.baidu.com/s/1eSJ7ciQ 密码: 1gj3

  4. 程序猿必备的Git教程

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 版权声明:本文为博主原创文章,未经 ...

  5. jinja2-宏,include, import

    一 宏 宏类似常规编程语言中的函数.它们用于把常用行为作为可重用的函数,取代 手动重复的工作.如果宏在不同的模板中定义,你需要首先使用 import,比如 {% macro input(name, v ...

  6. mysql数据库学习二

    最近又复习了mysql中的一些概念:视图,触发器,存储过程,函数,事务,记录下. 1.视图 视图是一个虚拟表,本身并不存储数据,当sql在操作视图时所有数据都是从其他表中查出来的,因此其本质是:根据S ...

  7. SQL-W3School-基础:SQL DISTINCT 语句

    ylbtech-SQL-W3School-基础:SQL DISTINCT 语句 1.返回顶部 1. 本章讲解 SELECT DISTINCT 语句. SQL SELECT DISTINCT 语句 在表 ...

  8. TransitionDrawable

    ayerDrawable的一个子类,TransitionDrawable只管理两层的Drawable!两层!两层! 并且提供了透明度变化的动画,可以控制一层Drawable过度到另一层Drawable ...

  9. C之数组

    1. 数组的地址就是数组里元素的首地址 2. 数组其实就是一块连续的内存空间 3. 每个元素所占大小取决于数组的类型 4. 所有指针变量在内存中的长度是一样的

  10. cls只能调用一次实例 第二次None

    class Zarten(): _singleton = None def __new__(cls, *args, **kwargs): print('__new__') if not cls._si ...