ZOJ Problem Set - 3601
There are n single boys and m single girls. Each of them may love none, one or several of other people unrequitedly and one-sidedly. For the coming q days, each night some of them will come together to hold a single party. In the party, if someone loves all the others, but is not loved by anyone, then he/she is called king/queen of unrequited love.
There are multiple test cases. The first line of the input is an integer T ≈ 50 indicating the number of test cases.
Each test case starts with three positive integers no more than
For each query, print the number of kings/queens of unrequited love, followed by their names in lexicographical order, separated by a space. Print an empty line after each test case. See sample for more details.
2 2 1 4 BoyA 1 GirlC BoyB 1 GirlC GirlC 1 BoyA 2 BoyA BoyB 2 BoyA GirlC 2 BoyB GirlC 3 BoyA BoyB GirlC 2 2 2 H 2 O S He 0 O 1 H S 1 H 3 H O S 4 H He O S
0 0 1 BoyB 0 0 0
Author: WU, Zejun
Contest: The 9th Zhejiang Provincial Collegiate Programming Contest