【bitset】Kth Minimum Clique

#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的更多相关文章
- Kth Minimum Clique
Kth Minimum Clique 题目描述 Given a vertex-weighted graph with N vertices, find out the K-th minimum wei ...
- 牛客竞赛第二场D Kth Minimum Clique 贪心+bitmap
Kth Minimum Clique 题意 给出n(n<100)个点的邻接表,和n个点的权值,求第k大的团(完全子图) 分析 n很小,并且好像没有什么算法和这个有关系,所以可以往暴力枚举的方向想 ...
- 【POJ2104】【HDU2665】K-th Number 主席树
[POJ2104][HDU2665]K-th Number Description You are working for Macrohard company in data structures d ...
- 【leetcode】963. Minimum Area Rectangle II
题目如下: Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from ...
- 【LeetCode】452. Minimum Number of Arrows to Burst Balloons 解题报告(Python)
[LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https ...
- 【题解】kth异或和/魔改版线性基
[题解]魔改版线性基 魔改版线性基解决此类问题. 联系线性空间的性质,我们直接可以构造出这样的基: \[ 100000 \\ 010000 \\ 000010 \\ 000001 \] 使得每个基的最 ...
- 牛客网多校训练第二场D Kth Minimum Clique
链接:https://ac.nowcoder.com/acm/contest/882/D来源:牛客网 Given a vertex-weighted graph with N vertices, fi ...
- 【LeetCode】Find Minimum in Rotated Sorted Array 解题报告
今天看到LeetCode OJ题目下方多了"Show Tags"功能.我觉着挺好,方便刚開始学习的人分类练习.同一时候也是解题时的思路提示. [题目] Suppose a sort ...
- 【leetcode】712. Minimum ASCII Delete Sum for Two Strings
题目如下: 解题思路:本题和[leetcode]583. Delete Operation for Two Strings 类似,区别在于word1[i] != word2[j]的时候,是删除word ...
随机推荐
- oracle中查询某个库中所有的表以及所占的表空间大小
1. 查某一用户下的表select SEGMENT_NAME,TABLESPACE_NAME,sum(BYTES/1024/1024)||'M' from USER_extents where SEG ...
- Maven:禁止编码指定类型的资源文件
[参考文章]:项目编译后dll文件调用出错 maven 在编译或项目时,可能会对资源文件进二次编码(编译前后的文件大小对比即可发现该问题),有些文件(例如:文本文件)可能不会影响我们是用,但是有些文件 ...
- YouTube 网站的架构演进——阅读心得
基础平台 Apache Python Linux(SuSe) MySQL psyco,一个动态的Python到C的编译器 lighttpd代替Apache做视频播放 状态 支持每天超过5亿的视频点击量 ...
- 讨论SQLite数据库损坏与修复
版权声明:博客将逐步迁移到 http://cwqqq.com https://blog.csdn.net/cwqcwk1/article/details/45541409 昨晚,朋友和我反馈SQL ...
- udp如何实现可靠性传输?
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 1udp与tcp的区别 TCP(TransmissionControl Protocol 传输控制协议)是一种面向连接的 ...
- TPCH测试工具
TPC现有的测试标准为:TPC-E.TPC-C.TPC-H.TPC-App.根据这4个测试基准,目前TPC主要包括的4个技术小组委员会:TPC-E 技术小组委员会.TPC-C 技术小组委员会.TPC- ...
- java递归复制文件夹
package com.haiyisoft.hyoaService; import java.io.BufferedInputStream;import java.io.BufferedOutputS ...
- set serveroutput on 命令
使用set serveroutput on 命令设置环境变量serveroutput为打开状态,从而使得pl/sql程序能够在SQL*plus中输出结果 使用函数dbms_output.put_lin ...
- Selenium下Chrome配置 (含启动无痕界面)
例子: 设置无界面模式浏览器启动chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') ...
- 将springboot安装成windows服务启动。
下载Windows Service Wrapper 本文下载了winsw-2.3.0-bin.exe. 新建一个目录aiplatformService 在目录里面新建一个aiplatformServi ...