CF1594C.Make Them Equal

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Theofanis has a string s1s2sns_1 s_2 \dots s_n and a character cc . He wants to make all characters of the string equal to cc using the minimum number of operations.

In one operation he can choose a number xx ( 1xn1 \le x \le n ) and for every position ii , where ii is not divisible by xx , replace sis_i with cc .

Find the minimum number of operations required to make all the characters equal to cc and the xx -s that he should use in his operations.

输入格式

The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

The first line of each test case contains the integer nn ( 3n31053 \le n \le 3 \cdot 10^5 ) and a lowercase Latin letter cc — the length of the string ss and the character the resulting string should consist of.

The second line of each test case contains a string ss of lowercase Latin letters — the initial string.

It is guaranteed that the sum of nn over all test cases does not exceed 31053 \cdot 10^5 .

输出格式

For each test case, firstly print one integer mm — the minimum number of operations required to make all the characters equal to cc .

Next, print mm integers x1,x2,,xmx_1, x_2, \dots, x_m ( 1xjn1 \le x_j \le n ) — the xx -s that should be used in the order they are given.

It can be proved that under given constraints, an answer always exists. If there are multiple answers, print any.

输入输出样例

  • 输入#1

    3
    4 a
    aaaa
    4 a
    baaa
    4 b
    bzyx

    输出#1

    0
    1
    2
    2 
    2 3

说明/提示

Let's describe what happens in the third test case:

  1. x1=2x_1 = 2 : we choose all positions that are not divisible by 22 and replace them, i. e. bzyx \rightarrow bzbx;
  2. x2=3x_2 = 3 : we choose all positions that are not divisible by 33 and replace them, i. e. bzbx \rightarrow bbbb.
首页