The members of a committee vote 'Yes' or 'No' on various issues. However, some pairs of
committee members have formed alliances, promising
never to cast opposite votes. No one is willing to vote contrary
to her own opinion, so some of the members may need to
abstain from voting in order to avoid conflict between allies.
We have devised a method to determine who
should abstain. Before each issue is voted on, we randomly assign each
committee member an identifying number, 1, 2, ..., n.
The member will then indicate her opinion on the issue. Then we will calculate
the smallest collection of abstentions that will avoid conflict.
The k-th element of the String[] voter contains the information about the
k-th committee member -- the first element describes the member whose id is 1,
the second describes the member whose id is 2, etc. Each element contains its member's
opinion, either 'Y' or 'N', followed by the identifying number of each higher-numbered member
who has formed an alliance with its member.
Return a int[]
containing, in ascending order, the identifying numbers of the minimal collection
of members who must abstain from voting. If there is more than one minimal collection,
return the one that is earliest lexicographically.
|