BZOJ 2530 Poi2011 Party


Description

Byteasar intends to throw up a party. Naturally, he would like it to be a success. Furthermore, Byteasar is quite certain that to make it so it suffices if all invited guests know each other. He is currently trying to come up with a list of his friends he would like to invite. Byteasar has friends, where is divisible by 3. Fortunately, most of Byteasar’s friends know one another. Furthermore, Byteasar recalls that he once attended a party where there were2/3 n of his friends, and where everyone knew everyone else. Unfortunately, Byteasar does not quite remember anything else from that party… In particular, he has no idea which of his friends attended it. Byteasar does not feel obliged to throw a huge party, but he would like to invite at least n/3of his friends. He has no idea how to choose them, so he asks you for help.
给定一张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<=[n(n-1)/2]

Input

In the first line of the standard input two integers, n and M(3<=N<=3000,[3/2 n(2/3 n -1)]/2<=M<=[n(n-1)/2]), are given, separated by a single space. These denote the number of Byteasar’s friends and the number of pairs of his friends who know each other, respectively. Byteasar’s friends are numbered from 1 to . Each of the following lines holds two integers separated by a single space. The numbers in line no.i+1(for i=1,2,…,m) are Ai and Bi(1<=Ai<Bi<=N), separated by a single space, which denote that the persons Ai and Bi now each other. Every pair of numbers appears at most once on the input.

Output

In the first and only line of the standard output your program should print N/3numbers, separated by single spaces, in increasing order. These number should specify the numbers of Byteasar’s friends whom he should invite to the party. As there are multiple solutions, pick one arbitrarily.

Sample Input

6 10
2 5
1 4
1 5
2 4
1 3
4 5
4 6
3 5
3 4
3 6

Sample Output

2 4

HINT

Explanation of the example: Byteasar’s friends numbered 1, 3, 4, 5 know one another. However, any pair of Byteasar’s friends who know each other, like 2 and 4 for instance, constitutes a correct solution, i.e., such a pair needs not be part of aforementioned quadruple.


首先如果任意两个点之间没有连边我们把这两个点删除
因为不在团里面的点最多有n/3​,每次删除两个点,团内的点也最多删除n/3​,最少也会剩下n/3个团内的点
所以最后直接在没有被删除的点里面取n/3​个就好了


 #include<bits/stdc++.h>
using namespace std;
#define fu(a,b,c) for(int a=b;a<=c;++a)
#define N 3010
int n,m;
bool vis[N],g[N][N];
int main(){
scanf("%d%d",&n,&m);
fu(i,,m){
int x,y;
scanf("%d%d",&x,&y);
g[x][y]=;
}
fu(i,,n)if(!vis[i])
fu(j,i+,n)if(!vis[j])
if(!g[i][j]){vis[i]=vis[j]=;break;}
int siz=;
fu(i,,n)if(!vis[i]&&siz<n/)printf("%d ",i),siz++;
}

BZOJ 2530 Poi2011 Party 【枚举】的更多相关文章

  1. bzoj 2530 [Poi2011]Party 构造

    2530: [Poi2011]Party Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 364  Solved:  ...

  2. [bzoj 2216] [Poi2011] Lightning Conductor

    [bzoj 2216] [Poi2011] Lightning Conductor Description 已知一个长度为n的序列a1,a2,-,an. 对于每个1<=i<=n,找到最小的 ...

  3. BZOJ.2527.[POI2011]MET-Meteors(整体二分)

    题目链接 BZOJ 洛谷 每个国家的答案可以二分+求前缀和,于是可以想到整体二分. 在每次Solve()中要更新所有国家得到的值,不同位置的空间站对应不同国家比较麻烦. 注意到每次Solve()其国家 ...

  4. bzoj 2277 [Poi2011]Strongbox 数论

    2277: [Poi2011]Strongbox Time Limit: 60 Sec  Memory Limit: 32 MBSubmit: 527  Solved: 231[Submit][Sta ...

  5. BZOJ 1050 旅行comf(枚举最小边-并查集)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1050 题意:给出一个带权图.求一条s到t的路径使得这条路径上最大最小边的比值最小? 思路 ...

  6. [BZOJ 2212] [Poi2011] Tree Rotations 【线段树合并】

    题目链接:BZOJ - 2212 题目分析 子树 x 内的逆序对个数为 :x 左子树内的逆序对个数 + x 右子树内的逆序对个数 + 跨越 x 左子树与右子树的逆序对. 左右子树内部的逆序对与是否交换 ...

  7. [BZOJ 2350] [Poi2011] Party 【Special】

    题目链接: BZOJ - 2350 题目分析 因为存在一个 2/3 n 大小的团,所以不在这个团中的点最多 1/3 n 个. 牺牲一些团内的点,每次让一个团内的点与一个不在团内的点抵消删除,最多牺牲 ...

  8. BZOJ 3713: [PA2014]Iloczyn( 枚举 )

    斐波那契数列<10^9的数很少很少...所以直接暴力枚举就行了... ------------------------------------------------------------- ...

  9. BZOJ 2212: [Poi2011]Tree Rotations( 线段树 )

    线段树的合并..对于一个点x, 我们只需考虑是否需要交换左右儿子, 递归处理左右儿子. #include<bits/stdc++.h> using namespace std; #defi ...

随机推荐

  1. GridView绑定数据源 绑定DataReader /DataSet /DataTable

    有一个GridView1 <asp:GridView ID="GridView1" runat="server"></asp:GridView ...

  2. bugfree登录后报错PHP Fatal error: Call-time pass-by-reference has been removed in

    详细报错信息[Tue Apr 25 06:49:07.556316 2017] [:error] [pid 21799] [client *.*.*.*:55813] PHP Fatal error: ...

  3. nginx+nagios使用用户名密码鉴权设置

    1.使用htpasswd生成密码 使用apache生成/usr/local/apache2/bin/htpasswd -c ./htpasswd.users nagiosadmin 拷贝到nginx的 ...

  4. 1-15-2-RAID1 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)

    大纲: 1.创建RAID1 2.创建RAID5 3.创建RAID10 =============================== 1.创建RAID1 RAID1原理:需要两块或以上磁盘,可添加热备 ...

  5. Lua学习笔记3. 函数可变参数和运算符、转义字符串、数组

    1. Lua函数可以接受变长数目的参数,和C语言类似,在函数的参数列表中使用(...)表示函数可以接受变长参数 lua函数将参数存放在一个table中,例如arg,那么#arg可以获得参数的个数 fu ...

  6. Jdev 本地RUN页面时候,将异常直接显示出来,而不是乱码

    本地运行页面时,经常会遇到以下错误 oracle.jbo.JboException: JBO-29000: JBO-29000: JBO-26028: ???? MemberAttributesDis ...

  7. C++复习8.异常处理和RTTI

    C++异常处理和RTTI技术 20130930 1.异常处理的基本知识 C语言中是没有内置运行时错误处理机制,对于错误发生的时候使用的几种处理机制: 函数返回彼此协商后统一定义的状态编码来表示操作成功 ...

  8. 【51nod-1315】合法整数集(数位)

    [思路] 既然是or操作,将数转化为二进制,数位是1,对应的数组元素+1,再将x转为成二进制,只要查找X为1的位置,将之前存放的数组数字找个最小的输出就可以了. 但是并不是所有的数都要参与or,因为有 ...

  9. 二十四、DBMS_SQL

    1.概述 1) 在整个程序的设计过程中,对游标的操作切不可有省略的部分,一旦省略其中某一步骤,则会程序编译过程既告失败,如在程序结尾处未对改游标进行关闭操作,则在再次调用过程时会出现错误. 2) db ...

  10. 最大匹配算法 (Maximum Matching)

    之所以研究这个算法,是因为最近在研究NLP中文的分词,所谓分词就是将一个完整的句子,例如“计算语言学课程有意思”,分解成一些词组单元“计算语言学,课程,有,意思”. “最大匹配法” 在中文分词中有所应 ...