编程介的小学生 2017-12-10 17:09 采纳率: 20.5%
浏览 778
已采纳

Adopt or not

Problem Description
A two-party system is a form of party system where two major political parties dominate voting in nearly all elections, at every level. As a result, all, or nearly all, elected offices end up being held by candidates endorsed by one of the two major parties.Under a two-party system, one of the two parties typically holds a plurality in the legislature , and is referred to as the majority party. The smaller party is referred to as the minority party. Two-party systems are most common in polities with plurality vote counting system to prevent the problem of two similar candidates "splitting" the same voters.
There is a small country under a two-party system, the two parties are party A and party B. Every time when parliament convened, members of both parties will submit Their proposals. Some of the proposals will be raised by some members of the same party, but each person can submit only one. Of course, some people may object to certain proposals of the other party. If a member's proposal is adopted and all his objection cases are not adopted, then he will be pleased. As the country's president, you can arrange these proposals is adopted or not. You want to know , to make the numnber of people pleased with your decision maximum, which proposals must be adopted ?

Input
On the first line one positive number: the number of testcases. After that per testcase:One line with three integers a, b, n (0<=a,b<=100 and 0<=n<=200): the number of proposals by party A, by party B, and number of members of the parliament. The proposals are numbered from 1 to a+b, the first a are party A's, the latter b are party B's.
n lines follow, each line represents a member of the parliament, begin with two integers ri,mi(1<=ri<=a+b, 0<=mi<a+b): the proposal submit by him, the number of proposals he object to. And then follows mi integers indicate the proposal he object to.

Output
For each test case, you should output 2 lines. The first line will contains one integer, the maxium number of people pleased. The second line begins with an integer x, indicates there are x proposals must be adopted. Then output the x proposals in ascending order of their id. There is a space between each two proposals.

Sample Input
3
2 1 3
1 0
1 0
3 0
2 1 3
1 0
2 1 3
3 0
2 1 4
1 0
1 1 3
2 0
3 2 1 2

Sample Output
3
2 1 3
2
1 1
3
2 1 2

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-11-14 10:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?