编程介的小学生
2017-12-03 04:36Adopt 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条回答
为你推荐
- Google Cloud SDK无法启动Docker映像Mac OS的预览
- docker
- revel
- 1个回答
- 当某些字段为只读字段而另一些字段为可空值时,如何使用Golang结构在API中执行CRUD?
- rest
- struct
- 1个回答
- Google的“ Go”语言多值返回语句是否可以替代异常?
- coding-style
- exception
- c++
- language-design
- 7个回答
- 如何在PHP中进行下拉基础MySQL查询
- php
- 1个回答
- BLOB over varchar?
- mysql
- php
- 4个回答