CQ天神 @ 2024-08-04 21:38:55
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int n,m;
cin>>n>>m;
string a,b;
cin>>a>>b;
vector<int> hashA,hashB;
for(int i=0;i<n;++i){
if(a[i]=='#') hashA.push_back(i);
if(b[i]=='#') hashB.push_back(i);
}
for(int i=0;i<m;++i){
char replaceChar='a'+(i%26);
if(!hashA.empty()){
int pos=hashA.front();
a[pos]=replaceChar;
hashA.erase(hashA.begin());
}else if(!hashB.empty()){
int pos=hashB.front();
b[pos]=replaceChar;
hashB.erase(hashB.begin());
}
}
cout<<a<<endl;
return 0;
}
by Anemones @ 2024-08-04 21:46:23
你样例都没过啊。。
by Anemones @ 2024-08-04 21:50:58
@CQ天神 你思路错了,按照你的代码思路就是abcde把a字符串全部填一遍啊。。
by CQ天神 @ 2024-08-04 21:55:17
@YuZeAn 那应该是怎么样的,
by Anemones @ 2024-08-04 22:19:02
@CQ天神 贪心思路是a字符串前面尽量设置为“a”,如果当前不是“a”就用b字符串凑到“a”
by CQ天神 @ 2024-08-05 07:54:26
@YuZeAn 谢谢