Ahws_rwhy @ 2024-08-03 22:13:32
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[100001], b[100001];
int sum, sum1;
int g;
int id;
bool flag = 0;
int t, t1;
int h;
int d = 0;
int f[100001];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == '#' && flag == 0) id = i, flag = 1;
if(a[i] == '#')
{
d++;
f[d] = i;
}
}
for (int i = 0; i < n; i++) cin >> b[i];
for (int i = 0; i < n; i++) {
if (a[i] == '#') {
sum++;
}
if (b[i] == '#') {
sum1++;
}
}
t = sum, t1 = sum1;
if(t == 0) {cout << a;return 0;}
if(t1 == 0)
{
for(int i = 0; i < n; i++)
{
if(a[i] == '#')
{
g++;
a[i] = 'a' + (g - 1) % 26;
}
}
cout << a;
return 0;
}
// cout << t << " " << t1 << endl;r
if (t1 < 26) {
for (int i = 0; i < n; i++)
if (a[i] == '#') g++, a[i] = 'a' + (g - 1) % 26;
}
// } else if (t1 >= 26) {
// while(sum1 > 26)
// {
// h++;
// a[f[h]] = 'a';
// g += 26;
// sum1 -= 25;
// }
// if (sum1 <= 26) {
for (int i = 0; i < n; i++) {
if (a[i] == '#') {
if(g + t1 >= 26 & g != 0)
{
t1 -= (26 - g);
g = 1;
a[i] = 'a' + (g - 1) % 26;
}
else
{
g++;
a[i] = 'a' + (g - 1) % 26;
}
}
}
cout << a;
return 0;
}
hack 数据:
in:
20 36
####################
################abcd
out:
abcdefghijklmnopqrst
right out:
abcdefghiabcdefghij
by Ahws_rwhy @ 2024-08-03 22:13:57
@ScaredQiu
by Mcfire05 @ 2024-08-03 22:19:18
@rwhy 这输出不对吧,n==20输出怎么才19位啊
by Ahws_rwhy @ 2024-08-03 22:20:41
@Mcfire05
right out:
abcdefghijabcdefghij
by ScaredQiu @ 2024-08-04 12:23:40
@rwhy 已经添加,虽然这个好像只能卡掉你的代码。