Vct14 @ 2024-09-30 13:41:44
#include<bits/stdc++.h>
using namespace std;
#define int long long
string a,b;
signed main(){
int n,m;cin>>n>>m>>a>>b;
int bs=0;
for(int i=0; i<n; i++) if(b[i]=='#') bs++;
// cout<<bs<<"\n";
if(bs==m){
cout<<a;
return 0;
}
if(n<=10 || bs==0){
int s=bs/25;int now='a';
for(int i=0; i<n; i++){
if(a[i]=='#'){
if(s){
cout<<"a";
s--;
}
else{
cout<<(char)now;
now++;
if(now=='z'+1) now='a';
}
}
else cout<<a[i];
}
return 0;
}
int s=bs/25;int y=(26-bs%25)%25;int now='a';bool f=false;
for(int i=0; i<n; i++){
if(a[i]=='#'){
if(s){
cout<<"a";
s--;
now='a';
if(f) now='b';
}
else{
cout<<(char)now;
now++;
if(now=='z'+1) now='a';
if(y>0) y--;
if(y==0 && !f) s++,f=true;
}
}
else cout<<a[i];
}
return 0;
}
by STRLEN_SUIYUHAN @ 2024-09-30 14:25:05
@Augenstern5
#include <bits/stdc++.h>
using namespace std;
int n, m, l2, g, id, f;
char s[200002], s2[200002], ls = 'a';
int main() {
cin >> n >> m >> s >> s2;
for (int i = 0; i < n; i ++) {
if (s[i] == '#' && f == 0) {
id = i;
f = 1;
}
if (s2[i] == '#') l2++;
}
for (int i = 0; i < n; i ++) {
if (s[i] != '#') cout << s[i];
else if (s[i] == '#') {
if (i == id) {
g++;
ls = 'a';
cout << ls;
continue;
}
if (l2 + g >= 26) {
l2 -= (26 - g), g = 1, ls = 'a';
cout << ls;
}
else {
g++;
ls = 'a' + (g - 1) % 26;
cout << ls;
}
}
}
return 0;
}
求关。
by Vct14 @ 2024-09-30 21:36:23
@STRLEN_SUIYUHAN ?别人求调代码你把自己 AC 代码贴出来有啥用?那别人为啥不直接看题解区看代码?只贴代码没什么,但是你还求关,你干了什么值得别人关注你?