- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
[PKU1112]TeamThemUp!巧妙构图动态规划
[PKU 1112]Team Them Up!
Team Them Up!
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2007 Accepted: 516 Special Judge Description
Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every team has at least one member; every person in the team knows every other person in his team; teams are as close in their sizes as possible. This task may have many solutions. You are to find and output any solution, or to report that the solution does not exist.
Input
For simplicity, all persons are assigned a unique integer identifier from 1 to N. The first line in the input file contains a single integer number N (2 = N = 100) - the total number of persons to divide into teams, followed by N lines - one line per person in ascending order of their identifiers. Each line contains the list of distinct numbers Aij (1 = Aij = N, Aij != i) separated by spaces. The list represents identifiers of persons that ith person knows. The list is terminated by 0.
Output
If the solution to the problem does not exist, then write a single message No solution (without quotes) to the output file. Otherwise write a solution on two lines. On the first line of the output file write the number of persons in the first team, followed by the identifiers of persons in the first team, placing one space before each identifier. On the second line describe the second team in the same way. You may write teams and identifiers of persons in a team in any order.
Sample Input
5
2 3 5 0
1 4 5 3 0
1 2 5 0
1 2 3 0
4 3 2 1 0
Sample Output
3 1 3 5
2 2 4
Source
Northeastern Europe 2001
题目大意:把n个人分成2各组,每一个人有他所认识的人。所分的组有四点要求:
1、?每个人都必需属于一个组。
2、?每个组至少有一个人。
3、?每个组里面的每个人必需互相认识。
4、?两个组的成员应尽量接近。
首先分析这道题目,题目给出的是一个有向图,即如果有A认识B,但不一定有B认识A。但是在所分配的组里面,任意两个人都要互相认识。
1、?先读入数据建立有向图,然后对这个有向图进行处理,如果两个点之间的边是单向边,就认为两个点之间无边(因为这两个人不互相认识),对于两个点间的双向边,即建立一条无向边(这两个人互相认识),这样就可以把一个有向图转化为一个无向图。
2、?将这个无向图转化为它的反图。即有边的把边删去,无边的添上一条边。(其实1,2步在程序实现时可以一次完成)。
3、?对转换后的反图求极大连通
您可能关注的文档
最近下载
- SY_T 5534-2019石油天然气钻采设备 油气田专用车通用技术规范.pdf
- 中职教师教学培训课件设计.pptx VIP
- 中南大学青年长江候选人贺治国.pdf VIP
- 山西垚志达煤业有限公司矿井瓦斯涌出量预测报告.doc
- 最全精装修检查验收表格.pdf VIP
- 高中英语教学资料-12月薪高考英语高一上英语试卷.doc VIP
- 马工程《民法学》(第二版)下册参考教学课件03-11民法学-第三编 合同 第十一章.pptx VIP
- 马工程《民法学》(第二版)下册参考教学课件03-10民法学-第三编 合同 第十章.pptx VIP
- 马工程《民法学》(第二版)下册参考教学课件03-09民法学-第三编 合同 第九章.pptx VIP
- 山东春考医学技术类模拟试题含答案.pdf VIP
文档评论(0)