# 【題解】Codeforces 1379A. Acacius and String

```#include <iostream>
using namespace std;

int T, n;
string s, t = "abacaba";

int main() {
cin >> T;
while (T--){
cin >> n;
cin >> s;
int cnt = 0;
int pos = -1;
for (int i = 0; i < n-6; i++){
bool flag[2] = {true, true};
for (int j = 0; j < 7; j++){
if (s[i+j] != t[j]){
flag[0] = false;
if (s[i+j] != '?'){
flag[1] = false;
break;
}
}
}
if (flag[0]) cnt++;
if (flag[1]){
if (i >= 6 && s.substr(i-6, 6) == t.substr(0, 6)) continue;
if (i >= 4 && s.substr(i-4, 4) == t.substr(0, 4)) continue;
if (n-i-6 > 4 && s.substr(i+7, 4) == t.substr(3, 4)) continue;
if (n-i-6 > 6 && s.substr(i+7, 6) == t.substr(1, 6)) continue;
pos = i;
}
}
if (cnt > 1) cout << "No\n";
else if (cnt == 1){
cout << "Yes\n";
for (int i = 0; i < n; i++){
if (s[i] != '?') cout << s[i];
else cout << 'd';
}
cout << "\n";
}
else if (pos >= 0){
for (int i = 0; i < 7; i++){
s[pos+i] = t[i];
}
cout << "Yes\n";
for (int i = 0; i < n; i++){
if (s[i] != '?') cout << s[i];
else cout << 'd';
}
cout << "\n";
}
else cout << "No\n";
}
}
```