CF1379A.Acacius and String

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Acacius is studying strings theory. Today he came with the following problem.

You are given a string ss of length nn consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once?

Each question mark should be replaced with exactly one lowercase English letter. For example, string "a?b?c" can be transformed into strings "aabbc" and "azbzc", but can't be transformed into strings "aabc", "a?bbc" and "babbc".

Occurrence of a string tt of length mm in the string ss of length nn as a substring is a index ii ( 1inm+11 \leq i \leq n - m + 1 ) such that string s[i..i+m1]s[i..i+m-1] consisting of mm consecutive symbols of ss starting from ii -th equals to string tt . For example string "ababa" has two occurrences of a string "aba" as a substring with i=1i = 1 and i=3i = 3 , but there are no occurrences of a string "aba" in the string "acba" as a substring.

Please help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once.

输入格式

First line of input contains an integer TT ( 1T50001 \leq T \leq 5000 ), number of test cases. TT pairs of lines with test case descriptions follow.

The first line of a test case description contains a single integer nn ( 7n507 \leq n \leq 50 ), length of a string ss .

The second line of a test case description contains string ss of length nn consisting of lowercase English letters and question marks.

输出格式

For each test case output an answer for it.

In case if there is no way to replace question marks in string ss with a lowercase English letters in such a way that there is exactly one occurrence of a string "abacaba" in the resulting string as a substring output "No".

Otherwise output "Yes" and in the next line output a resulting string consisting of nn lowercase English letters. If there are multiple possible strings, output any.

You may print every letter in "Yes" and "No" in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).

输入输出样例

  • 输入#1

    6
    7
    abacaba
    7
    ???????
    11
    aba?abacaba
    11
    abacaba?aba
    15
    asdf???f???qwer
    11
    abacabacaba

    输出#1

    Yes
    abacaba
    Yes
    abacaba
    Yes
    abadabacaba
    Yes
    abacabadaba
    No
    No

说明/提示

In first example there is exactly one occurrence of a string "abacaba" in the string "abacaba" as a substring.

In second example seven question marks can be replaced with any seven lowercase English letters and with "abacaba" in particular.

In sixth example there are two occurrences of a string "abacaba" as a substring.

首页