Brazilian FootXOR
시간 제한0.5초메모리 제한2048 MB
N개의 이진 벡터를 같은 크기의 두 팀으로 나눠 XOR이 같게 만들거나 불가능을 보고하는 문제.
문제
Alex is coaching the famous Brazilian FootXOR Club. For today’s training, they want to organize a match between two teams selected from the club members. To ensure a fair match, the two teams must be balanced.
Each club member has a set of abilities represented as a -digit binary string. Each digit corresponds to a characteristic that the player may or may not have. Surprisingly, it is not the quantity of players having each characteristic that matters when deciding whether two teams are balanced: the important thing is the parity of that quantity.
Two teams are considered balanced if they have the same number of players and the bitwise XOR of the ability strings of all players in the first team is equal to the bitwise XOR of the ability strings of all players in the second team. Of course, each club member can only be assigned to at most one team and, for a match to happen, teams cannot be empty.
Alex is really busy right now. As their coaching assistant, you must determine how to assign players to the two teams. If it is impossible to fulfill the coach’s conditions, you must inform the coach accordingly.
입력
The first line contains two integers and (), indicating respectively the number of club members and the number of binary digits used to represent their abilities. Each club member is identified by a distinct integer from to .
The -th of the next lines contains a -digit binary string , representing the abilities of club member . Note that has a fixed length and so it may contain leading zeros.
출력
Output a single line with a string of length if it is possible to fulfill the coach’s conditions. In this case, the -th character of the string must be a digit “1”, “2” or “0”, indicating respectively that club member is assigned to the first team, to the second team, or to none of the two teams. If there are multiple solutions, output any of them.
If the coach’s conditions cannot be honored, output the character “*” (asterisk) instead.