首页 > 其他分享 >AcWing杯 - 第66场周赛

AcWing杯 - 第66场周赛

时间:2022-08-28 07:55:20浏览次数:90  
标签:周赛 typedef str int long 66 include AcWing

比赛链接:[第 66 场周赛](竞赛 - AcWing)

先放代码,题解慢慢补

A AcWing 4606. 奇偶判断

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

int main()
{
    string str;
    cin>>str;
    int num=str[str.length()-1]-'0';
    printf("%d\n",num%2);
    return 0;
}

B AcWing 4607. 字母补全

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

const int N=1e5+5;

char a[N];
int n;
int cnt[26];

int main()
{
//  freopen("1.in","r",stdin);
    scanf("%s",a);
    n=strlen(a);
    int pos=-1;
    for(int i=0;i+25<n;i++) {
        memset(cnt,0,sizeof cnt);

        bool flag=true;
        for(int j=i;j<=i+25;j++) {
            if(a[j]=='?') continue;
            else if(cnt[a[j]-'A']) {
                flag=false;
                break;
            }
            else cnt[a[j]-'A']++;
        }
        if(flag) {
            pos=i;
            break;
        }
    }
    if(pos==-1) return puts("-1")&0;
    for(int i=pos;i<=pos+25;i++) {
        if(a[i]!='?') continue;
        for(int j=0;j<26;j++) {
            if(!cnt[j]) {
                a[i]='A'+j;
                cnt[j]++;
                break;
            }
        }
    }
    for(int i=0;i<n;i++) {
        if(a[i]=='?') a[i]='A';
        putchar(a[i]);
    }
    puts("");
    return 0;
}

C AcWing 4608. 整数分组

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

const int N=100+5;

int n,m;
int cnt[N],a[N];
int sum[N];

int main()
{
//  freopen("1.in","r",stdin);
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        m=max(m,a[i]);
        cnt[a[i]]++;
    }

    for(int i=1;i<=m;i++) {
        if(cnt[i]==2 || cnt[i]==0) continue;
        else if(cnt[i]==1) sum[1]++;
        else sum[3]++;
    }
    if(sum[1]%2==0) {
        puts("YES");
        int tmp=0;
        for(int i=1;i<=n;i++) {
            if(cnt[a[i]]==2) putchar('A');
            else if(cnt[a[i]]==1) {
                tmp++;
                if(tmp<=sum[1]/2) putchar('A');
                else putchar('B');
            }
            else putchar('A');
        }
    }
    else if(sum[3]==0) puts("NO");
    else {
        puts("YES");
        int tmp=0;
        bool flag=false;
        int supernum=0;
        for(int i=1;i<=n;i++) 
            if(cnt[a[i]]>2) {
                supernum=a[i];
                break;
            }
        for(int i=1;i<=n;i++) {
            if(cnt[a[i]]==2) putchar('A');
            else if(cnt[a[i]]==1) {
                tmp++;
                if(tmp<=sum[1]/2) putchar('A');
                else putchar('B');
            }
            else if(!flag && a[i]==supernum){
                flag=true;
                putchar('A');
            }
            else putchar('B');
        }
    }
    return 0;
}

标签:周赛,typedef,str,int,long,66,include,AcWing
From: https://www.cnblogs.com/cjl-world/p/16631948.html

相关文章

  • AtCoder Beginner Contest 266 A-D
    AtCoderBeginnerContest266https://atcoder.jp/contests/abc266EF待补A-MiddleLetter输出字符串最中间的那个字母#include<bits/stdc++.h>usingnamespace......
  • 【重要】LeetCode 662. 二叉树最大宽度
    题目链接注意事项根据满二叉树的节点编号规则:若根节点编号为u,则其左子节点编号为u<<1,其右节点编号为u<<1|1。一个朴素的想法是:我们在DFS过程中使用两个哈希表......
  • Atcoder ABC 266 EF
    E题目大意有一个游戏,你可以玩\(n\)次,每次投一个骰子,若数字为\(X\),则:若这把是第\(n\)把,那么你的分数为\(X\),游戏结束否则,你可以选择继续游戏,或者立刻停止游戏,分数为\(X......
  • 662. 二叉树最大宽度
    662.二叉树最大宽度给你一棵二叉树的根节点root,返回树的最大宽度。树的最大宽度是所有层中最大的宽度。每一层的宽度被定义为该层最左和最右的非空节点......
  • ABC266总结
    比赛情况AC:6/8排名:830题目分析A(语法)直接输出\(s_{n/2+1}\)即可点击查看代码//Problem:A-MiddleLetter//Contest:AtCoder-AtCoderBeginnerContest......
  • Acwing 第 66 场周赛 A-C
    2A,来晚+中间有事,第三题没写,但是写第三题的时候也感觉犯迷糊,读懂题意就好了AAcWing4606.奇偶判断题意:判断末位是偶数还是奇数跳过 BAcWing4607.字母补全题意......
  • 第 66 场周赛 ABC
    A-奇偶判断#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<int,int>PII;constLLN=200200;LLa[N],b[N];#definexfirst#defi......
  • 2022网鼎杯网鼎杯web669wp
    大致思路:1.任意文件读取2.session伪造3.untar目录穿越,任意文件写4.yaml反序列化5.sudidd提权任意文件读取题目代码importosimportreimportyamlimporttime......
  • 战66 WIN11 亮度热键 快捷键无效
    型号:HPZHAN66ProA14G3。用FN调节音量是正常的,唯独亮度无效。 参考:怎样调节笔记本电脑屏幕亮度(惠普笔记本亮度调节快捷键失灵)|说明书网(shuomingshu.cn)。打......
  • NC16663 合并果子
    题目原题地址:合并果子题目编号:NC16663题目类型:队列、堆时间限制:C/C++1秒,其他语言2秒空间限制:C/C++131072K,其他语言262144K1.题目大意n堆果子,需要两两合并直至......