CF1250E.The Coronation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present.
The King has ordered his jeweler to assemble n beautiful necklaces, so each of the princesses could wear exactly one necklace during the ceremony — and now these necklaces are finished. Each necklace consists of m gems attached to a gold chain. There are two types of gems used in the necklaces — emeralds and sapphires. So, each necklace can be represented by a sequence of m gems (listed from left to right), and each gem is either an emerald or a sapphire. Formally, the i -th necklace can be represented by a binary string si of length m ; if the j -th character of si is 0, then the j -th gem in the i -th necklace is an emerald; otherwise, this gem is a sapphire.
Now, looking at the necklaces, the King is afraid that some of his daughters may envy the other daughters' necklaces. He wants all necklaces to look similar. Two necklaces are considered similar if there are at least k positions where these necklaces contain the same type of gems.
For example, if there is a necklace represented by a sequence 01010111 and a necklace represented by a sequence 01100000, then there are 3 positions where these necklaces contain the same type of gems (both first gems are emeralds, both second gems are sapphires, and both fifth gems are emeralds). So if k=3 , these necklaces are similar, and if k=4 , they are not similar.
The King thinks that if two of his daughters notice that their necklaces are not similar, then they may have a conflict — and, obviously, he doesn't want any conflicts during the coronation! So Berl XXII wants to tell some of his daughters to wear their necklaces backward. If a necklace is worn backward, then the sequence of gems in this necklace is reversed. For example, if a necklace is represented by a sequence 01100, then, if worn backward, it would be represented by a sequence 00110. The King wants to find the minimum number of necklaces to be worn backward during the coronation so that there are no conflicts.
Berl XXII is too busy with preparation for the coronation, so he ordered you to resolve this issue for him. Help him — and he will give you a truly royal reward!
输入格式
The first line contains one integer t ( 1≤t≤50 ) — the number of test cases. Then the test cases follow.
Each test case begins with a line containing three integers n , m and k ( 2≤n≤50 , 1≤k≤m≤50 ) — the number of necklaces, the number of gems in each necklace, and the minimum number of positions where two necklaces have to have the same type of gems in order to look similar, respectively.
Then n lines follow, the i -th of them contains a binary string si of length m representing the i -th necklace.
输出格式
For each test case, print the answer as follows.
If it is impossible to avoid the conflict, print -1 on a single line. In this case you should not output anything else for that test case.
Otherwise, the first line of the test case answer should contain the single integer d — the minimum number of necklaces that are to be worn backward. The second line of the test case answer should contain the numbers of these necklaces (integers from 1 to n ) in any order. If d=0 then leave the second line of the test case answer empty. If there are multiple answers, you may print any of them.
输入输出样例
输入#1
5 5 7 2 1010100 0010101 1111010 1000010 0000101 6 9 3 011111110 100111000 111100000 000111111 110100111 111110111 3 4 2 0001 1000 0000 3 4 4 0001 1000 0000 2 4 3 0001 1000
输出#1
2 1 3 1 3 0 -1 1 1