regina11 @ 2024-08-03 18:22:40
求调
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
const int N = 1e5 + 10;
long long i, n, m, cnta, cntb, pos[N];
string a, b;
int main()
{
cin >> n >> m;
cin >> a >> b;
for (i = 0; i < n; i++) {
if (a[i] == '#') {
pos[cnta] = i;
cnta++;
}
if (b[i] == '#') {
cntb++;
}
}
if (cnta == 0) {
cout << a << endl;
return 0;
}
long long cnt = 0;
for (i = 0; i < m; i++) {
if (cntb < 25 || i % 26 == 0) {
a[pos[cnt]] = char(i % 26 + 'a');
cnt++;
if (cnt == cnta)
break;
}
else {
cntb -= 25;
i += 24;
}
}
cout << a << endl;
return 0;
}
by cha_mu @ 2024-08-06 13:00:32
emm,少个判定,你想如果你b字符串还剩几个字符没有用,如果省的那些可以帮a字符串凑一个a的话字典数便更小了
by regina11 @ 2024-08-07 09:52:13
@cha_mu
if (cntb < 25 || i % 26 == 0) {
a[pos[cnt]] = char(i % 26 + 'a');
cnt++;
if (cnt == cnta)
break;
}
else {
cntb -= 25;
i += 24;
}
求问这里加的判定不可以吗?cntb是b里还剩的#个数,如果cntb>=25,仍可用b帮a字符串凑一个a
by regina11 @ 2024-08-07 12:37:41
@cha_mu 看了您那篇帖子样例三解释与没拿满分原因已经明白了,感谢回复!%%%