Codeforces Round 747 (Div. 2)
C
Make Them Equal
Codeforces
1200
原题
← BD →
翻译中…

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

翻译中…

In one operation he can choose a number $x$ ($1 \le x \le n$) and for every position $i$, where $i$ is not divisible by $x$, replace $s_i$ with $c$.

翻译中…

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

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

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

翻译中…

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

翻译中…

Output

翻译中…

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

翻译中…

Next, print $m$ integers $x_1, x_2, \dots, x_m$ ($1 \le x_j \le n$) — the $x$-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.

翻译中…

Note

翻译中…

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

翻译中…
  1. $x_1 = 2$: we choose all positions that are not divisible by $2$ and replace them, i. e. bzyx $\rightarrow$ bzbx;
  2. $x_2 = 3$: we choose all positions that are not divisible by $3$ and replace them, i. e. bzbx $\rightarrow$ bbbb.
翻译中…

样例

Input #1
3
4 a
aaaa
4 a
baaa
4 b
bzyx
Output #1
0
1
2
2
2 3
InputCopy OutputCopy
题目信息
题号
1594C
时间限制
2 s
内存限制
256 MB
标签
暴力
贪心
数学
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。