提交时间:2026-04-06 15:23:30

运行 ID: 435505

#include <iostream> #include <string> using namespace std; int main() { string s, t; cin >> s >> t; string res(s.size(), 'Z'); int n = s.size(), m = t.size(); for (int i = 0; i <= n - m; i++) { string now = s; bool f = 1; for (int j = 0; j < m; j++) { if (now[i+j] != '?' && now[i+j] != t[j]) { f = 0; break; } now[i+j] = t[j]; } if (!f) continue; for (char &c : now) if (c == '?') c = 'A'; if (now < res) res = now; } cout << res << endl; return 0; }