BZOJ2530 : [Poi2011]Party】的更多相关文章

题目链接 BZOJ2530 题解 如果我们删去一对不连边的仍然存在的点的话,这对点肯定不同时在那个\(\frac{2}{3}n\)的团中,也就是说,每次删点至少删掉一个外点,至多删掉一个内点 那么我们要删掉团外的点最多使用\(\frac{1}{3}n\)个团内的点就可以了,剩下的至少\(\frac{1}{3}n\)个点就在一个团内 #include<algorithm> #include<iostream> #include<cstring> #include<c…
注意到随机一组贪心解得到的团的大小不小于$\frac{N}{3}$的概率是很大的,所以一直随机下去,直到找到一组解即可,随机次数是常数级别的,所以复杂度为$O(n^2)$. #include<cstdio> #include<cstdlib> #define N 3010 int n,m,i,j,k,a[N],del[N],fin[N];bool g[N][N]; inline void swap(int&a,int&b){int c=a;a=b;b=c;} inl…
POI2011题解 2214先咕一会... [BZOJ2212][POI2011]Tree Rotations 线段树合并模板题. #include<cstdio> #include<algorithm> using namespace std; int gi(){ int x=0,w=1;char ch=getchar(); while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if (ch=='-') w=0…
[BZOJ2530][Poi2011]Party Description 给定一张N(保证N是3的倍数)个节点M条边的图,并且保证该图存在一个大小至少为2N/3的团. 请输出该图的任意一个大小为N/3的团. 一个团的定义为节点的一个子集,该子集中的点两两有直接连边. 输入: 第一行是两个整数N,M. 接下来有M行,每行两个整数A,B,表示A和B有连边.保证无重边. 输出: N/3个整数,表示你找到的团. 数据范围:  3<=N<=3000,[3/2 n(2/3 n -1)]/2<=M&l…
补一发题解.. 整体二分这个东西,一开始感觉复杂度不是很靠谱的样子 问了po姐姐,说套主定理硬干.. #include<bits/stdc++.h> #define ll long long #define inf 1e9 #define N 300005 using namespace std; inline int read(){ ,f=;char ch=getchar(); ;ch=getchar();} *x+ch-';ch=getchar();} return x*f; } int…
2276: [Poi2011]Temperature Time Limit: 20 Sec  Memory Limit: 32 MBSubmit: 293  Solved: 117[Submit][Status] Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The measurement is done automatically, and its res…
2213: [Poi2011]Difference Time Limit: 10 Sec  Memory Limit: 32 MBSubmit: 343  Solved: 108[Submit][Status] Description A word consisting of lower-case letters of the English alphabet ('a'-'z') is given. We would like to choose a non-empty contiguous (…
2212: [Poi2011]Tree Rotations Time Limit: 20 Sec  Memory Limit: 259 MBSubmit: 391  Solved: 127[Submit][Status] Description Byteasar the gardener is growing a rare tree called Rotatus Informatikus. It has some interesting features: The tree consists o…
线段树的合并..对于一个点x, 我们只需考虑是否需要交换左右儿子, 递归处理左右儿子. #include<bits/stdc++.h> using namespace std; #define M(l, r) (((l) + (r)) >> 1) typedef long long ll; ; ; struct Node *null, *pt; struct Node { Node *l, *r; int cnt; Node() : cnt() { l = r = null; }…
2217: [Poi2011]Lollipop Time Limit: 15 Sec  Memory Limit: 64 MBSec  Special JudgeSubmit: 383  Solved: 159[Submit][Status][Discuss] Description 有一个长度为n的序列a1,a2,...,an.其中ai要么是1("W"),要么是2("T"). 现在有m个询问,每个询问是询问有没有一个连续的子序列,满足其和为q. Input 第一行…