旺仔哥哥想将每个 `?` 改成小写英文字母,使字符串
输出任何这样的可能的改写后的字符串,如果没有符合条件的字符串存在,则直接报告不可能即可。
第一行包含一个整数(
) - 测试用例数。
每个测试用例的第一行包含一个字符串(
,且
仅由小写英文字母和 ```?``` 组成。
每个测试用例的第二行包含一个字符串(
且
仅由小写英文字母组成)--该字符串本应是字符串
的子序列。
所有测试用例中的总和不超过
,其中
表示字符串
的长度。
对于每个测试用例,如果不存在语句中描述的字符串,则输出 "NO"(不带引号)。
否则,输出 "YES"(不带引号)。然后,输出一行--符合所有条件的字符串。
如果可能有多个答案,您可以输出其中任何一个。
4 ??a???e????ba efe cbe??????e?b???b be a???bf????? deadaeefb f???bf?efc?eeebac? afbacea
YES efaeaaeaaaaba YES cbeaaaaaaeabaaab NO YES fafbbfaefceeeebaca
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
cin.ignore();
for (int ti=0; ti<t; ++ti) {
string ss,st;
getline(cin, ss);
getline(cin, st);
int ht = 0;
string ans = ss;
for (int i=0; i<ss.size(); ++i) {
if (ht<st.size()) {
if (ss[i]=='?' || ss[i]==st[ht]) {
ans[i] = st[ht];
ht += 1;
}
}
else {
if (ss[i]=='?') ans[i]='a';
}
}
if (ht!=st.size()) cout << "NO" << endl; else {
cout << "YES" << endl << ans << endl;
}
}
}
// 64 位输出请用 printf("%lld") #include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
for (int i = 0; i < T; i++) {
string s,t;
cin >> s >> t;
int tLeftIndex = 0;
int tRightIndex = 0;
for (int j = 0; j < s.size(); j++) {
if (tLeftIndex < t.size()) {
if (s[j] == '?') {
s[j] = t[tLeftIndex];
tLeftIndex++;
} else {
if (s[j] == t[tLeftIndex]) {
tLeftIndex++;
}
}
} else {
if (s[j] == '?') {
s[j] = 'a';
}
}
}
if (tLeftIndex == t.size()) {
cout << "YES" << endl;
cout << s << endl;
} else {
cout << "NO" << endl;
}
}
} import re n = int(input()) for num in range(n): s = input() t = input() find = re.findall(r'\?+', s) length = sum(len(i) for i in find) total = 0 for i in t: total += s.count(i) if length >= len(t): print('YES') t = t + 'a' * (length - len(t)) left = 0 right = 0 while len(s) > right: if s[right] == '?': s = s.replace(s[right], t[left], 1) left += 1 right += 1 print(s) elif s.count('?') + total >= len(t): left = 0 right = 0 flag = 'NO' while len(s) > right: if s[right] == t[left]: left += 1 elif s[right] == '?' and left < len(t): s = s.replace(s[right], t[left], 1) left += 1 if left == len(t): flag = 'YES' break right += 1 print(flag) if flag == 'YES': if s.count('?') != 0: s = s.replace('?', 'a') print(s) else: print('NO')
import sys
a = [ i.replace('\n','') for i in list(sys.stdin)]
n = int(a[0])
a.pop(0)
for i in range(n):
if len(a[2*i+1]) > len(a[2*i]):
print("NO")
else:
x = list()
for n in a[2*i]:
count = 0
if len(a[2*i+1]) > 0:
for j in a[2*i+1]:
if n =="?":
x.append(j)
a[2*i+1] = a[2*i+1][1:]
break
elif n == j:
x.append(j)
a[2*i+1] = a[2*i+1][1:]
break
else:
x.append(n)
break
else:
if n =="?":
x.append("a")
else:
x.append(n)
if len(x)>len(a[2*i])&nbs***bsp;len(a[2*i+1])>0:
print("NO")
else:
print("YES")
print("".join(x))