CF1250E.The Coronation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The coronation of King Berl XXII is soon! The whole royal family, including nn daughters of Berl XXII, will be present.

The King has ordered his jeweler to assemble nn 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 mm 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 mm gems (listed from left to right), and each gem is either an emerald or a sapphire. Formally, the ii -th necklace can be represented by a binary string sis_i of length mm ; if the jj -th character of sis_i is 0, then the jj -th gem in the ii -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 kk 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 33 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=3k = 3 , these necklaces are similar, and if k=4k = 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 tt ( 1t501 \le t \le 50 ) — the number of test cases. Then the test cases follow.

Each test case begins with a line containing three integers nn , mm and kk ( 2n502 \le n \le 50 , 1km501 \le k \le m \le 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 nn lines follow, the ii -th of them contains a binary string sis_i of length mm representing the ii -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 dd — 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 11 to nn ) in any order. If d=0d = 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 
    
首页