#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. 注解之@RequestParam和@GetMapping

    @RequestParam用来处理Content-Type 为 application/x-www-form-urlencoded编码的内容,将请求参数名映射到方法参数名.在Http协议中,如果不指定 ...

  2. Java高并发下的 “单例模式”

    前言:单例模式大家应该很熟悉了,我在这里就自己总结一下自己这段时间学到的单例相关的知识. 单例模式的目的:保证一个类只有单一的实例,也就是说你无法通过new来创建这个类的一个新实例. 单例模式的意义: ...

  3. [BJOI2019]奥术神杖——AC自动机+DP+分数规划+二分答案

    题目链接: [BJOI2019]奥术神杖 答案是$ans=\sqrt[c]{\prod_{i=1}^{c}v_{i}}=(\prod_{i=1}^{c}v_{i})^{\frac{1}{c}}$. 这 ...

  4. jinja2-宏,include, import

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

  5. Nginx中配置非英文域名

    前两天遇到个配置越南语的域名的情况.域名和ip解析完成后,直接ping域名也不通,还以为是解析问题.研究了半天,nginx配置非英文域名时,需要有其他操作. 非英文域名转换成punycode编码才可以 ...

  6. 20182332 实验一《Linux基础与Java开发环境》实验报告

    20182332 实验一<Linux基础与Java开发环境>实验报告 课程:<程序设计与数据结构> 班级: 1823 姓名: 盛国榕 学号:20182332 实验教师:王志强 ...

  7. ehcache快速入门

    前言 JAVA缓存实现方案有很多,最基本的自己使用Map去构建缓存,或者使用memcached或Redis,但是上述两种缓存框架都要搭建服务器,而Map自行构建的缓存可能没有很高的使用效率,那么我们可 ...

  8. PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)

    1016 Phone Bills (25 分)   A long-distance telephone company charges its customers by the following r ...

  9. Ubuntu+Django+uWSGI+Nginx部署Django项目

    安装uWSGI,pip依据自己要使用的python版本自行选择,python2.x版本使用pip进行安装,python3.x版本使用pip3进行安装 pip install uwsgi 配置uWSGI ...

  10. 【leetcode】507. Perfect Number

    problem 507. Perfect Number solution: /* class Solution { public: bool checkPerfectNumber(int num) { ...