2530: [Poi2011]Party
2017-01-18 19:12
507 查看
2530: [Poi2011]Party
Time Limit: 10 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 247 Solved: 142
[Submit][Status][Discuss]
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 currentlytrying 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.
[align=left]给定一张N(保证N是3的倍数)个节点M条边的图,并且保证该图存在一个大小至少为2N/3的团。[/align]
请输出该图的任意一个大小为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 numberof 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 heshould invite to the party. As there are multiple solutions, pick one arbitrarily.
Sample Input
6 102 5
1 4
1 5
2 4
1 3
4 5
4 6
3 5
3 4
3 6
Sample Output
2 4HINT
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 aforementionedquadruple.
请不要提交!
Source
鸣谢 Object022&suhang[Submit][Status][Discuss]
保证了至少三分之二的点在同一个团里面
每次任意选择一对没有边相连的点删除,执行n / 3次,这样最后剩n / 3个点
显然,这些点都在一个团里面
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<vector> #include<queue> #include<set> #include<map> #include<stack> #include<bitset> #include<ext/pb_ds/priority_queue.hpp> using namespace std; const int maxn = 3003; int n,m,tot; bool del[maxn],G[maxn][maxn]; int getint() { char ch = getchar(); int ret = 0; while (ch < '0' || '9' < ch) ch = getchar(); while ('0' <= ch && ch <= '9') ret = ret*10 + ch - '0',ch = getchar(); return ret; } int main() { #ifdef DMC freopen("DMC.txt","r",stdin); #endif n = getint(); m = getint(); while (m--) { int x = getint(),y = getint(); G[x][y] = G[y][x] = 1; } for (int i = 1; i < n; i++) { if (del[i]) continue; for (int j = i + 1; j <= n; j++) { if (del[j]) continue; if (!G[i][j]) {del[i] = del[j] = 1; break;} } } for (int i = 1; i <= n; i++) { if (del[i]) continue; ++tot; if (tot < n / 3) printf("%d ",i); else {cout << i; break;} } return 0; }
相关文章推荐
- bzoj 2530: [Poi2011]Party
- bzoj 2530: [Poi2011]Party
- BZOJ2530: [Poi2011]Party
- 【BZOJ2530】[Poi2011]Party (xia)构造
- BZOJ2530 : [Poi2011]Party
- BZOJ 2530: [Poi2011]Party
- BZOJ2530 [Poi2011]Party 【贪心】
- bzoj2530 [Poi2011]Party
- BZOJ2530 [Poi2011]Party
- BZOJ 2530 Poi2011 Party 构造
- [构造] BZOJ 2530 [Poi2011]Party
- [BZOJ 2350] [Poi2011] Party 【Special】
- 洛谷 3524 [POI2011]IMP-Party
- BZOJ2530 [Poi2011]Party
- [POI 2011]Party(构造)
- 【BZOJ】【P2530】【Poi2011】【Party】【题解】【水题】
- 【BZOJ2525】[Poi2011]Dynamite 二分+树形DP
- 2276: [Poi2011]Temperature
- 【POI2011】【BZOJ2280】Plot
- 【bzoj 2527】[Poi2011]Meteors