• Codeforces Beta Round #55 (Div. 2)


    B题

    #include <iostream>
    #include<stdio.h>
    #include<string.h>
    using namespace std;
    
    int main()
    {
    int n,a,sum=0,min=101;
    scanf("%d",&n);
    while(n--)
    {
    scanf("%d",&a);
    sum+=a;
    if(a%2==1&&a<min)
    {
    min=a;
    }
    }
    if(sum%2==1)printf("%d
    ",sum);
    else if(min<101)printf("%d
    ",sum-min);
    else printf("0
    ");
    return 0;
    }
    AC code

    C题:

    #include <iostream>
    #include<stdio.h>
    #include <string.h>
    #include <math.h>
    
    using namespace std;
    
    int main()
    {
        char s1[105];
        char s2[105];
        int zimu[27];
        char out[105];
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            memset(zimu,0,sizeof(zimu));
            scanf("%s",s2);
            int L=strlen(s2);
            strcpy(s1,s2);
            _strrev(s2);
    
            int judge=1;
            for(int i=0;i<L;i++)
            {
                if(s1[i]!='?')
                {
                    zimu[s1[i]-'a']=1;
                }
                if(s1[i]!=s2[i])
                {
                    if(s1[i]=='?')
                    {
                        s1[i]=s2[i];
                        //printf("s1  %c %d
    ",s1[i],i);
                    }
                    else if(s2[i]=='?')
                    {
                        s2[i]=s1[i];
                    }
                    else
                    {
                        judge=0;
                        break;
                    }
                }
            }
    
           /*for(int i=0;i<L;i++)
            printf("%c",s2[i]);
            printf("###
    ");
    
            for(int i=0;i<L;i++)
            printf("%c",s1[i]);
            printf("***
    ");*/
    
            if(judge==0){printf("IMPOSSIBLE
    ");}
            else
            {
                for(int j=L/2;j>=0;j--)
                {
    
                    if(s1[j]=='?')
                    {
                        int i;
                        for(i=n-1;i>=0;i--)
                        {
                            if(zimu[i]!=1)
                            {
                                out[j]=i+'a';
                                s1[j]=i+'a';
                                out[L-j-1]=i+'a';
                                s1[L-j-1]=i+'a';
                                zimu[i]=1;
                                break;
                            }
                        }
                        if(i==-1)
                        {
                            out[j]='a';
                            out[L-j-1]='a';
                        }
                    }
                    else {
                        out[j]=s1[j];
                        out[L-j-1]=s1[L-j-1];
                    }
    
                }
    
                int j;
                for(j=0;j<n;j++)
                {
                    if(zimu[j]!=1)break;
                }
                if(j==n){
                for(int k=0;k<L;k++)
                {
                    printf("%c",out[k]);
                }
                printf("
    ");
                }
                else printf("IMPOSSIBLE
    ");
            }
        }
        return 0;
    }
    C题 ac code

    D题:

    /********************
    AC
    Time:2013-10-30
    *******************************/
    #include <iostream>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include <algorithm>
    using namespace std;
    int num[100003][4];
    int nnum[300010];
    int num1[100003];
    
    int min(int a,int b,int c)
    {
        if(nnum[a]<=nnum[b]&&nnum[a]<=nnum[c])
        {
            return a;
        }
        else if(nnum[b]<=nnum[a]&&nnum[b]<=nnum[c])
        return b;
        else
         return c;
    }
    int main()
    {
        int n;
        int i,j,k;
        int mnum;
        while(scanf("%d",&n)!=EOF)
        {
            int judge=0;
            for(i=1;i<=3*n;i++)
            {
                scanf("%d",&mnum);
                nnum[mnum]=i;
            }
            for(i=1;i<=n;i++)
            {
                scanf("%d %d %d",&num[i][1],&num[i][2],&num[i][3]);
                num[i][0]=min(num[i][1],num[i][2],num[i][3]);
            }
            scanf("%d",&k);
            for(i=1;i<=n;i++)
            {
                if(num[i][0]==k)
                {
                    judge=1;
                    break;
                }
            }
            if(judge==0)
            {
                for(i=1;i<3*n;i++)
                {
                    if(i!=k)
                    printf("%d ",i);
                }
                printf("%d
    ",3*n);
            }
            else
            {
                int m=0;
                int judge2=0;
                for(i=1;i<=n;i++)
                {
                    for(j=1;j<=3;j++)
                    {
                        if(num[i][j]!=k)
                        num1[m++]=num[i][j];
                        else
                        judge2=1;
                    }
                    if(judge2==1)break;
                }
                sort(num1,num1+m);
                int duiyuan=0;
                for(j=0;j<m&&duiyuan<2;j++)
                {
                    if(num1[j]==num[i][1]||num1[j]==num[i][2]||num1[j]==num[i][3])
                    duiyuan++;
                }
                    for(int ii=i+1;ii<=n;ii++)
                    {
                        for(int jj=1;jj<=3;jj++)
                        {
                            num1[m++]=num[ii][jj];
                        }
                    }
                if(i!=n)sort(&num1[j],num1+m);
    
                for(int ii=0;ii<m;ii++)
                {
                    if(ii!=0)
                    printf(" ");
                    printf("%d",num1[ii]);
                }
                printf("
    ");
    
            }
        }
        return 0;
    }
    D题 ac code
  • 相关阅读:
    Vue实现上下整屏滚动效果
    Vue实现选项卡切换效果
    Vue中在main.js中引入字体图标问题
    Vue中的生命周期beforeDestory不触发问题
    Vue中解决移动端点击300毫秒延迟的问题
    Vue中全局和按需引入Echarts
    Vue组件间的通信
    Echarts图表属性设置
    JZOJ 6799. 【2014广州市选day2】game
    JZOJ 6798. 【2014广州市选day2】regions
  • 原文地址:https://www.cnblogs.com/ACshasow/p/3413850.html
Copyright © 2020-2023  润新知