• Acwing第 66 场周赛【完结】


    https://www.acwing.com/activity/content/2224/

    4606. 奇偶判断

    #include
    using namespace std;
    int main(void)
    {
        string s; cin>>s;
        int temp=s[s.size()-1]-'0';
        cout<<temp%2;
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    4607. 字母补全

    在这里插入图片描述

    #include
    using namespace std;
    int main(void)
    {
        string s; cin>>s;
        for(int i=0;i<s.size();i++)
        {
            if( (i+25) > (s.size()-1) ) continue;
            int cnt[32]={0},flag=1;
            for(int j=i;j<=i+25;j++)
            {
                if(s[j]=='?') continue;
                else
                {
                    int c=s[j]-'A';
                    if(cnt[c]) flag=0;
                    cnt[c]++;
                }
            }
            if(flag)
            {
                queue<char>q,ans;
                for(int j=0;j<i;j++) 
                    if(s[j]=='?') ans.push('A');
                    else ans.push(s[j]);
                for(int j=0;j<=25;j++) if(!cnt[j]) q.push('A'+j);
                for(int j=i;j<=i+25;j++) 
                    if(s[j]=='?') 
                    {
                        ans.push(q.front());
                        q.pop();
                    }
                    else ans.push(s[j]);
                for(int j=i+26;j<s.size();j++)
                {
                    if(s[j]=='?') ans.push('A');
                    else ans.push(s[j]);
                }
                while(ans.size()) cout<<ans.front(),ans.pop();
                return 0;
            }
        }
        cout<<-1;
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    4608. 整数分组

    在这里插入图片描述

    #include
    using namespace std;
    int n,a[105],cnt1,cnt2,cnt3;
    //cnt1 个数为1
    //cnt2 个数为2
    //cnt3 个数大于2
    map<int,int>mp;
    int main(void)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>a[i],mp[a[i]]++;
        for(auto i=mp.begin();i!=mp.end();i++)
        {
            int cnt=i->second;
            if(cnt==1) cnt1++;
            if(cnt==2) cnt2++;
            if(cnt>2)  cnt3++;
        }
        
        if(cnt1&&cnt1%2==0)//只有1,且为偶数
        {
            puts("YES");
            int st[105]={0},temp=0;
            for(int i=0;i<n;i++)
            {
                if(mp[a[i]]==1) st[i]=1,temp++;
                if(temp==cnt1/2) break;
            }
            for(int i=0;i<n;i++) 
                if(st[i]) cout<<"A";
                else cout<<"B";
            return 0;
        }
        
        if(cnt2&&!cnt1&&!cnt3)//只有cnt2, 0/0 即可
        {
            puts("YES");
            for(int i=0;i<n;i++) cout<<"A";
            return 0;
        }
        
        if(cnt3&&!cnt1)//只有cnt3, 0/0 即可
        {
            puts("YES");
            for(int i=0;i<n;i++) cout<<"A";
            return 0;
        }
        
        if(cnt3&&cnt1)//1,3 从3中拿出一个来平分
        {
            puts("YES");
            int st[105]={0},temp=0;
            for(int i=0;i<n;i++)
            {
                if(mp[a[i]]>2) 
                {
                    st[i]=1,temp++;
                    break;
                }
            }
            for(int i=0;i<n;i++)
            {
                if(temp==(cnt1+1)/2) break;
                if(mp[a[i]]==1) st[i]=1,temp++;
            }
            for(int i=0;i<n;i++) 
                if(st[i]) cout<<"A";
                else cout<<"B";
            return 0;
        }
        puts("NO");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
  • 相关阅读:
    15 HTTPS协议详解
    AI创作专家,免费的AI创作专家工具
    TortoiseSVN小乌龟的使用
    HTTP1.1强制缓存和协商缓存
    大数据——Spark SQL
    PyCharm:2023新版PyCharm无UI工具栏,如何回旧版
    Spring Boot 系列 —— Spring Webflux
    [De1CTF 2019]SSRF Me
    SourceTree提示128错误
    elementPlus + table 树形懒加载 新增,删除,修改 局部刷新
  • 原文地址:https://blog.csdn.net/qq_46527915/article/details/126572420