• vijos 1379 字符串的展开


    23333333333333333

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define maxn 1005000
    char s[maxn],t[maxn],p[maxn];
    int p1,p2,p3,top=-1,l;
    void work(int x)
    {
        int l=s[x-1],r=s[x+1],cnt=0;
        if ((s[x-1]<='9') && (s[x+1]>'9')) {t[++top]='-';return;}
        if ((s[x-1]=='-') || (s[x+1]=='-')) {t[++top]='-';return;}
        for (int i=l+1;i<=r-1;i++)
        {
            for (int j=1;j<=p2;j++)
            {
                if (p1==3)
                {
                    p[++cnt]='*';
                    continue;
                }
                if ((s[x-1]>='0') && (s[x-1]<='9'))
                    p[++cnt]=i;
                else
                {
                    if (p1==1) p[++cnt]=i;
                    else if (p1==2) p[++cnt]=i-32;
                }
            }
        }
        if (p3==1)
        {
            for (int i=1;i<=cnt;i++)
                t[++top]=p[i];
        }
        else
        {
            for (int i=1;i<=cnt;i++)
                t[++top]=p[cnt-i+1];
        }
    }
    int main()
    {
        scanf("%d%d%d",&p1,&p2,&p3);
        scanf("%s",s);
        l=strlen(s);
        for (int i=0;i<l;i++)
        {
            if (s[i]!='-')
                t[++top]=s[i];
            else
            {
                if (i==0) {t[++top]='-';continue;}
                if (i==l-1) {t[++top]='-';continue;}
                if (s[i-1]==s[i+1]) t[++top]=s[i];
                else if (s[i-1]>s[i+1]) t[++top]=s[i];
                else work(i);
            }
        }
        printf("%s",t);
        return 0;
    }
  • 相关阅读:
    xcode构建webdriverAgent时报错Messaging unqualified id的解决办法
    ubuntu18.0安装RabbitMQ
    python中*的用法
    Jenkins构建项目
    Jenkins安装与配置
    git_仓库
    六、 Shell数组应用
    五、 Shell函数应用
    三、 Shell流程控制
    二、 Shell变量定义
  • 原文地址:https://www.cnblogs.com/ziliuziliu/p/5860409.html
Copyright © 2020-2023  润新知