Codeforces Round #747 (Div. 2), problem: (C) Make Them Equal,

C. Make Them Equal
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Theofanis has a string s1s2…sn 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≤x≤n) and for every position i, where i is not divisible by x, replace si 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≤t≤104) — the number of test cases.

The first line of each test case contains the integer n (3≤n≤3⋅105) 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⋅105.

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 x1,x2,…,xm (1≤xj≤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.

Example
inputCopy
3
4 a
aaaa
4 a
baaa
4 b
bzyx
outputCopy
0
1
2
2
2 3
Note
Let’s describe what happens in the third test case:

x1=2: we choose all positions that are not divisible by 2 and replace them, i. e. bzyx → bzbx;
x2=3: we choose all positions that are not divisible by 3 and replace them, i. e. bzbx → bbbb.
题意:给定一个字符串和一个给定的字符和任意给定的m个的x,需要将给定的字符串变成有给定字符的串,对于在字符串中和给定字符不一样的字符的替换规则是:

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值