70pts 求助

P10836 『FLA - I』歌静河

OIer6666 @ 2024-08-03 18:38:08

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    ios::sync_with_stdio(false);
    string a,b;
    int n,m;
    cin>>n>>m>>a>>b;
    int t=0;
    for(int i=0;i<n;i++)if(b[i]=='#')t++;
    int l=floor(t/26.0);
    t=26-(t-l*26)+1;
    int x=0,y=1,z=0;
    for(int i=0;i<n;i++){
        if(a[i]=='#'){
            if(z<l){
                a[i]='a';
                z++;
            }else{
                if((y-1)%26+1==t&&t!=1){
                    y=1;
                    t=0;
                }else if(t==1&&(y-1)%26+1==2){
                    t=26;
                    y=1;
                }
                a[i]=(y-1)%26+'a';
                y++;
            }
        }
    }
    cout<<a;
    return 0;
}

WA:7、8、9


|