BestCoder Round #48 ($)HDU5285 wyh2000 and pupil
来源:互联网 发布:des 算法 函数原理图 编辑:程序博客网 时间:2024/05/18 16:40
wyh2000 and pupil
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1239 Accepted Submission(s): 384
Problem Description
Young theoretical computer scientist wyh2000 is teaching his pupils.
Wyh2000 has n pupils.Id of them are from 1 to n.In order to increase the cohesion between pupils,wyh2000 decide to divide them into 2 groups.Each group has at least 1 pupil.
Now that some pupils don't know each other(if a doesn't know b,then b doesn't know a).Wyh2000 hopes that if two pupils are in the same group,then they know each other,and the pupils of the first group must be as much as possible.
Please help wyh2000 determine the pupils of first group and second group. If there is no solution, print "Poor wyh".
Wyh2000 has n pupils.Id of them are from 1 to n.In order to increase the cohesion between pupils,wyh2000 decide to divide them into 2 groups.Each group has at least 1 pupil.
Now that some pupils don't know each other(if a doesn't know b,then b doesn't know a).Wyh2000 hopes that if two pupils are in the same group,then they know each other,and the pupils of the first group must be as much as possible.
Please help wyh2000 determine the pupils of first group and second group. If there is no solution, print "Poor wyh".
Input
In the first line, there is an integer T indicates the number of test cases.
For each case, the first line contains two integersn,m indicate the number of pupil and the number of pupils don't konw each other.
In the next m lines,each line contains 2 intergersx,y(x <y) ,indicates that x don't know y and y don't know x,the pair (x,y) will only appear once.
T≤10,0≤n,m≤100000
For each case, the first line contains two integers
In the next m lines,each line contains 2 intergers
Output
For each case, output the answer.
Sample Input
28 53 45 61 25 83 55 42 34 53 42 4
Sample Output
5 3Poor wyh
Source
BestCoder Round #48 ($)
出题人:
如果a不认识b,那么在a,b间连一条边,这样有解当且仅当这张图是二分图。
由于可能有多个二分图,而题目要求第一组的人尽可能多,所以贪心的选择即可。
要注意m=0的情况。
0 0
- BestCoder Round #48 ($)HDU5285 wyh2000 and pupil
- hdu5285 wyh2000 and pupil
- HDU5285.wyh2000 and pupil
- [hdu5285]wyh2000 and pupil
- 二分图判定 hdu5285 wyh2000 and pupil
- HDU5285:wyh2000 and pupil(二分图染色 & 贪心)
- wyh2000 and pupil
- wyh2000 and pupil
- BestCoder Round #48 ($) wyh2000 and a string problem
- HDU-5284-wyh2000 and a string problem(BestCoder Round #48 ($))
- BestCoder Round #48 ($)HDU5284 wyh2000 and a string problem
- hdu 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- HDU 5285:wyh2000 and pupil
- hdu 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- 第一阶段总结
- 安装weiphp遇到的问题
- pyhon中常见的文件处理
- 无法打开物理文件 操作系统错误 5:拒绝访问 SQL Sever
- java 多线程 cpu 通俗易懂
- BestCoder Round #48 ($)HDU5285 wyh2000 and pupil
- BS学习 一 搭建 struts
- 通知中心
- readn writen readline函数源代码
- GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助
- Codeforces 584E. Anton and Ira (排列好题)
- Gson源码的研读-2015/10/9
- 起个名字好难:关于变量命名的思考与总结
- 归并排序