fork download
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3. // #include<bits/stdc++.h>
  4. #include <iostream>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include <algorithm>
  8. #include <cmath>
  9. #include <vector>
  10. #include <list>
  11. #include <set>
  12. #include <map>
  13. #include <unordered_set>
  14. #include <unordered_map>
  15. #include <queue>
  16. #include <ctime>
  17. #include <cassert>
  18. #include <complex>
  19. #include <stack>
  20. #include <string>
  21. #include <cstring>
  22. #include <chrono>
  23. #include <random>
  24. #include <bitset>
  25. #include <sstream>
  26. #include <iomanip>
  27. using namespace std;
  28.  
  29.  
  30. #define int int64_t
  31. #define vi vector<int>
  32. #define vb vector<bool>
  33. #define vbb vector< vector<bool> >
  34. #define all(x) (x).begin(), (x).end()
  35. #define vii vector< vector<int> >
  36. #define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
  37. #define ff first
  38. #define ss second
  39. #define pii pair<int64_t, int64_t>
  40. #define miv map<int, vector<int> >
  41. #define mp make_pair
  42. #define pb push_back
  43. #define prr(x) cout << (#x) <<' ' << (x) << endl
  44. #define pr(x) cout << (x) << endl
  45. #define f(i,n) for(i=0;i<n;i++)
  46. #define pqb priority_queue<int>
  47. #define pqs priority_queue<int,vi,greater<int> >
  48. #define setbits(x) __builtin_popcountll(x)
  49. #define zrobits(x) __builtin_ctzll(x)
  50. #define mod 1000000007
  51. #define inf 1e18
  52. #define ps(x,y) fixed<<setprecision(y)<<x
  53. #define mk(arr,n,type) type *arr=new type[n];
  54. #define w(x) int x; cin>>x; while(x--)
  55. #define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  56. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  57.  
  58. int32_t main()
  59. {
  60. FIO;
  61. int i, n, j, m, k, l, t;
  62. cin >> t;
  63. while(t--)
  64. {
  65. cin >> n;
  66. string s;cin >> s;
  67. string s1="abacaba";
  68. k=0;
  69. for(i=0;i<=n-s1.length();i++)
  70. {
  71. string ss = s.substr(i, s1.length());
  72. bool bb=true;
  73. for(j=0;j<s1.length();j++)
  74. if(ss[j]!=s1[j]) bb=false;
  75.  
  76. if(bb)
  77. k++;
  78.  
  79. }
  80.  
  81.  
  82. if(k>1)
  83. {
  84. cout << "No\n";
  85. }
  86.  
  87. else if(k==1)
  88. {
  89. f(i,n) if(s[i]=='?') s[i]='z';
  90.  
  91. cout << "Yes\n" << s << endl;
  92. }
  93.  
  94.  
  95.  
  96. else
  97. {
  98. for(i=0;i<=n-s1.length();i++)
  99. {
  100. string ss = s.substr(i, s1.length());
  101. bool bb=true;
  102. for(j=0;j<s1.length();j++)
  103. {
  104. if(ss[j]!='?') {if(ss[j]!=s1[j]) bb=false;}
  105. }
  106. if(bb)
  107. {
  108. k++;
  109. for(j=i;j<i+s1.length();j++) s[j]=s1[j-i];
  110. f(l,n) if(s[l]=='?') s[l]='z';
  111. k=0;
  112. break;
  113.  
  114. }
  115. }
  116.  
  117. for(i=0;i<=n-s1.length();i++)
  118. {
  119.  
  120. string ss = s.substr(i, s1.length());
  121. bool bb=true;
  122. for(j=0;j<s1.length();j++)
  123. if(ss[j]!=s1[j]) bb=false;
  124.  
  125.  
  126. if(bb)
  127. k++;
  128.  
  129. }
  130.  
  131. if(k==1)
  132. cout << "Yes\n" << s << endl;
  133.  
  134. if(k==0)
  135. cout << "No\n";
  136.  
  137. if(k>1)
  138. cout << "No\n";
  139.  
  140. }
  141.  
  142. }
  143. }
  144.  
Runtime error #stdin #stdout #stderr 0s 4564KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 1) > this->size() (which is 0)