90分求调
查看原帖
90分求调
677609
Vct14楼主2024/9/30 13:41
#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;
}
2024/9/30 13:41
加载中...