Description The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that…
http://codeforces.com/problemset/problem/527/D 题意:给出一些点的xi和wi,当|xi−xj|≥wi+wj的时候,两点间存在一条边,找出一个最大的集合,集合中的点两两之间存在边 化开有 xi-xj>=wi+wj ==> wj+xj<=wi-xi xj-xi>=wi+wj ==> wi+wx<=wj-xj 发现本质相同,我们按x+w排序,从最小的往大的贪心连边,因为如果有一条边,那么比它小的也全部可以连到边. #include…
题解: 水题 两种做法: 1.我的 我们假设$xi>xj$ 那么拆开绝对值 $$xi-w[i]>x[j]+w[j]$$ 由于$w[i]>0$,所以$x[i]+w[i]>x[j]+w[j]$ 然后我们只需要在线段树上查询一段的最大值然后再单点取max就行了 #include <bits/stdc++.h> using namespace std; #define rint register int #define IL inline #define rep(i,h,t)…
这题说的是给了n个位置 在x轴上 每个位置有一个权值为wi,然后将|xi - xj|>=wi+wj ,满足这个条件的点建一条边,计算着整张图中有多少多少个点构成的子图,使得这个子图的节点数尽量的大,这个式子进行转变 我们可以知道离i这个点为wi+xi xi-wi 范围内的点都是不可以的,那么我们就将这个n个点转化为了n条线段,那么现在的任务是计算这个n条线段两两不想交的 最大数量, 对于每条 线段有 左端点和右端点,我们将他们进行右端点排序, 然后进行每条边的判断前面k条线段的最右边那条是否与当…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
传送门 D. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated…
[codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
B - Clique Problem 题目大意:给你坐标轴上n个点,每个点的权值为wi,两个点之间有边当且仅当 |xi - xj| >= wi + wj, 问你两两之间都有边的最大点集的大小. 思路:其实问题能转换为一堆线段问你最多能挑出多少个线段使其两两不相交.. 对于一个点来说可以变成[x - wi, x + wi]这样一条线段.. 然后贪心取就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #def…
题目链接: B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulate…