求助
查看原帖
求助
626849
xiatiantian楼主2024/8/3 19:48
#include<bits/stdc++.h>
using namespace std;
int n, m;
string a, b;
int cnt;
char s;
int main(){
	cin >> n >> m >> a >> b;
	s = 'a';
	for(int i = 0; i <= n - 1; i++)
		if(b[i] == '#') cnt++;
	for(int i = 0; i <= n - 1; i++){
		if(a[i] == '#'){
			if(s != 'a'&& cnt >= 'z' - s + 1) 
					s = 'a', cnt -= 'z' - s + 1;
			a[i] = s;
			s = s == 'z' ? 'a' : s + 1;
		}
	}
	cout << a << '\n';
	return 0;
}

为什么这个代码只要把s = 'a'放在后面就可以过了?

2024/8/3 19:48
加载中...