20分求助!!!
查看原帖
20分求助!!!
373226
justinjia楼主2021/1/3 16:17

R44577621 记录详情

测试点结果:

#1#2#3#4#5#6#7#8#9#10WAACWAACWAWAWAWAWAWA\begin{matrix} \#1&\#2&\#3&\#4&\#5&\#6&\#7&\#8&\#9&\#10\\ \colorbox{red}{\color{white}WA}&\colorbox{green}{\color{white}AC}&\colorbox{red}{\color{white}WA}&\colorbox{green}{\color{white}AC}&\colorbox{red}{\color{white}WA}&\colorbox{red}{\color{white}WA}&\colorbox{red}{\color{white}WA}&\colorbox{red}{\color{white}WA}&\colorbox{red}{\color{white}WA}&\colorbox{red}{\color{white}WA} \end{matrix}

源代码:

#include"stdio.h"
#include"string"
#include"ctype.h"
using namespace std;
string readstr(void){//快读string
    string ans="";
    char tmp;
    do{
        tmp=getchar();
        ans+=tmp;
    }while(tmp!=' '&&tmp!='\n'&&tmp!=EOF);
    ans.erase(ans.size()-1,1);
    return ans;
}
void writestr(string a){//“快写”string
    for(int i=0;i<a.size();i++)
        putchar(a[i]);
}
string str_char(char a){//char转string
    string ans="";
    ans+=a;
    return ans;
}
int main(void){
    string a;
    int p1,p2,p3;
    scanf("%d%d%d",&p1,&p2,&p3);
    a=readstr();
    a=readstr();
    for(int i=1;i<a.size()-1;i++)
        if(a[i]=='-')
            if((isdigit(a[i-1])&&isdigit(a[i+1])||islower(a[i-1])&&islower(a[i+1])||isupper(a[i-1])&&isupper(a[i+1]))&&a[i-1]<a[i+1]){
                a.erase(i--,1);
                if(p1==3)
                    for(int j=0;j<a[i+1]-a[i-1]-1;j++)
                        for(int k=0;k<p2;k++)
                            a.insert(++i,"*");
                else{
                    if(isdigit(a[i-1])&&isdigit(a[i+1])){
                        if(p3==1)
                            for(char j=a[i-1]+1;j<a[i+1];j++)
                                for(int k=0;k<p2;k++)
                                    a.insert(++i,str_char(j));
                        else
                            for(char j=a[i+1]-1;j>a[i-1];j--)
                                for(int k=0;k<p2;k++)
                                    a.insert(++i,str_char(j));
                    }else{
                        if(p1==1){
                            if(p3==1)
                                for(char j=tolower(a[i-1])+1;j<tolower(a[i+1]);j++)
                                    for(int k=0;k<p2;k++)
                                        a.insert(++i,str_char(j));
                            else
                                for(char j=tolower(a[i+1])-1;j>tolower(a[i-1]);j++)
                                    for(int k=0;k<p2;k++)
                                        a.insert(++i,str_char(j));
                        }else{
                            if(p3==1)
                                for(char j=toupper(a[i-1])+1;j<toupper(a[i+1]);j++)
                                    for(int k=0;k<p2;k++)
                                        a.insert(++i,str_char(j));
                            else
                                for(char j=toupper(a[i+1])-1;j>toupper(a[i-1]);j++)
                                    for(int k=0;k<p2;k++)
                                        a.insert(++i,str_char(j));
                        }
                    }
                }
            }
    writestr(a);
    return 0;
}
2021/1/3 16:17
加载中...