70分求调!!!

P10836 『FLA - I』歌静河

__HappY__ @ 2024-08-19 20:37:28

#include<bits/stdc++.h>
using namespace std;
int n, m;
string a, b;
int j = 0;
int tot = 1;
int main() {
    cin >> n >> m;
    cin >> a >> b;
    for(int i = 1; i <= n; i++) {
        if(a[i - 1] == '#') j++;
    }
    if(j == 0) {
        cout << a;
        return 0;
    }
    j = m - j;
    if(j == 0) {
        for(int i = 0; i < n; i++) {
            if(a[i] == '#') {
                cout << (char) ((tot - 1) % 26 + 'a');
                tot++;
            }
            else cout << a[i];
        }
        return 0;
    }
    for(int i = 0; i < n; i++) {
        if(a[i] == '#') {
            if(j >= 26) {
                cout << 'a';
                j -= 26;
            }
            else {
                cout << (char) ((tot - 1) % 26 + 'a');
                tot++;
            }
        }
        else cout << a[i];
    }
    return 0;
}

也可以给 hack 数据

悬赏一枚关注


by __rnfmabj__ @ 2024-08-19 20:57:18

30 60 ############################## ##############################

答案:aabcdefghijklmnopqrstuabcdefgh

这个题我之前在机房讲过,专门讲这一种情况的

@ HappY


by __rnfmabj__ @ 2024-08-19 20:58:02

格式炸了,用这个

30 60 
############################## 
##############################

答案:aabcdefghijklmnopqrstuabcdefgh

|