#P12044. Algorithm Duel Team Building

    ID: 14150 Type: Default 1000ms 256MiB

Algorithm Duel Team Building

Algorithm Duel Team Building

In the club, there are n members and a problem bank of m = 3n-3 algorithm problems. In a standard Algorithm Duel team building activity, for every problem the number of members who have not solved it must be even, so that they can be paired up for a duel. However, it turns out that no non‐empty subset of the members can satisfy this condition.

To hold an activity nonetheless, the organizer (Krucal-chan) decides to join the activity herself and “fix” the parity issue by awarding bonus points. Specifically, she is allowed to choose any number of problems between n and m-n+1 (recall that m-n+1 = 2n-2) to gift to one chosen member. When a bonus is given, that member is regarded as having solved that problem regardless of his or her original status. In other words, if in the invited set S a problem j has an odd number of members who have not solved it, then by choosing a bonus candidate x ∈ S with A[x,j] = 0 (i.e. x originally did not solve problem j) and awarding that problem, the count decreases by one – making it even. For problems where x already solved them, the parity must already be even. Let the bonus count for x be the number of problems j for which x did not solve the problem and the total number of members in S who did not solve problem j is odd. The activity becomes a non‐standard team building activity if there exists an invited set S (a nonempty subset of the club) and a bonus candidate x in S such that:

  • For every problem j with A[x, j] = 1 (i.e. x solved j), the number of members in S who did not solve j is even.
  • If we let bonus be the number of problems j with A[x, j] = 0 and an odd unsolved count in S, then bonus must lie in the interval [n, 2n-2].

Your task is to choose which members to invite. In other words, given an n × m binary matrix (with m = 3n-3) where each row represents a member’s status on each problem (1 indicates solved, 0 indicates unsolved – and it is guaranteed that each member has at least one unsolved problem), you need to output an invited set S and designate one bonus candidate x ∈ S that turns the activity into a non‐standard team building activity.

Input Format: The first line contains the integer n. The next n lines each contain a binary string of length m = 3n-3. The j-th character on the i-th line is '1' if the i-th member solved problem j, and '0' otherwise.

Output Format: If a valid solution exists, output three lines. The first line is an integer k representing the number of invited members. The second line contains k distinct integers (1-indexed) denoting the indices of the invited members. The third line contains a single integer representing the index of the bonus candidate within the invited set. It is guaranteed that a solution exists.

inputFormat

The first line contains an integer n. The next n lines each contain a binary string of length m = 3n-3, representing each member’s solved status on the m problems.

outputFormat

Output three lines: the first is the number k of invited members; the second is k space‐separated integers (the invited members’ indices, 1-indexed); the third is the index of the bonus candidate (which must be one of the invited members).

sample

2
111
100
2

1 2 2

</p>