menu ZJOJ
account_circle 请登录
home
首页
book
题目
apps
分类
play_circle_outline
状态
assessment
竞赛
assignment
作业
equalizer
排名
assignment_ind
登录
person_add
注册
1569: 部落卫队
时间限制:1.000s
内存限制:128MB

题目描述

原始部落中的居民们为了争夺有限的资源,经常发生冲突。几乎每个居民都有他的仇敌。部落酋长为了组织一支保卫部落的队伍,希望从部落的居民中选出最多的居民入伍,并保证队伍中任何 lns="http://www.w3.org/1998/Math/MathML">2 个人都不是仇敌。

给定部落中居民间的仇敌关系,编程计算组成部落卫队的最佳方案。若有多种方案可行,输出字典序最大的方案。


输入格式

第 lns="http://www.w3.org/1998/Math/MathML">1 行有 lns="http://www.w3.org/1998/Math/MathML">2 个正整数 lns="http://www.w3.org/1998/Math/MathML">n 和 lns="http://www.w3.org/1998/Math/MathML">m,表示 部落中有 lns="http://www.w3.org/1998/Math/MathML">n 个居民,居民间有 lns="http://www.w3.org/1998/Math/MathML">m 个仇敌关系。居民编号为 lns="http://www.w3.org/1998/Math/MathML">1,2, \cdots ,n。接下来的 lns="http://www.w3.org/1998/Math/MathML">m 行中,每行有 lns="http://www.w3.org/1998/Math/MathML">2 个正整数 lns="http://www.w3.org/1998/Math/MathML">u 和 lns="http://www.w3.org/1998/Math/MathML">v,表示居民 lns="http://www.w3.org/1998/Math/MathML">u 与居民 lns="http://www.w3.org/1998/Math/MathML">v 是仇敌。

输出格式

第 lns="http://www.w3.org/1998/Math/MathML">1 行是部落卫队的人数;文件的第 lns="http://www.w3.org/1998/Math/MathML">2 行是卫队组成 lns="http://www.w3.org/1998/Math/MathML">x_ilns="http://www.w3.org/1998/Math/MathML">1 \le i \le nlns="http://www.w3.org/1998/Math/MathML">x_i=0 表示居民 lns="http://www.w3.org/1998/Math/MathML">i 不在卫队中,lns="http://www.w3.org/1998/Math/MathML">x_i=1 表示居民 lns="http://www.w3.org/1998/Math/MathML">i 在卫队中。

样例输入 content_copy

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

样例输出 content_copy

3
1 0 1 0 0 0 1

提示/说明

对于 lns="http://www.w3.org/1998/Math/MathML">60\% 数据:lns="http://www.w3.org/1998/Math/MathML">n \le 20lns="http://www.w3.org/1998/Math/MathML">m \le 100

对于所有数据:lns="http://www.w3.org/1998/Math/MathML">n \le 100,m \le 3000。数据从所有合法数据从随机均匀取样。

分类