首页 > 其他分享 >ACWING 第 76 场周赛 ABC

ACWING 第 76 场周赛 ABC

时间:2022-11-07 17:36:26浏览次数:74  
标签:周赛 typedef ABC const LL cin long 76 tie

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

这场周赛也很简单,除了C我在赛场上写的时候有点小bug,赛时没改出来,哎,真废啊

4713. 反转字符串

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL INF=1e9;
const LL N=5000200,M=2002;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        string s,c;
        cin>>s>>c;
        bool flag=true;
        reverse(s.begin(),s.end());
        if(s==c) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

4714. 数对

手动模拟一下就可以找到规律

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL INF=1e9;
const LL N=5000200,M=2002;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        map<char,LL> mp;
        for(LL i=0;i<s.size();i++)
        {
            mp[s[i]]++;
        }
        LL sum=0;
        for(LL i=48;i<=57;i++)
        {
            char op=(char)i;
            //cout<<op<<" ";
            sum+=(LL)(mp[op]*mp[op]);
        }
        for(int i=97;i<=122;i++)
        {
            char op=(char)i;
            //cout<<op<<" ";
            sum+=(LL)(mp[op]*mp[op]);
        }
        cout<<sum<<endl;
        mp.clear();
    }
    return 0;
}

4715. 构造数组

题目大意:

按照字符串给出的相邻两两数字的比较,构造出这样的数组。

一定会有答案。
输入样例1:
5
><><
输出样例1:
2 1 2 1 2
输入样例2:
5
=<<<
输出样例2:
1 1 2 3 4

数据范围在2000内,直接暴力。固定往后找的同时,遇到不符合条件的直接回溯更正。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=200200,M=2002;
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL n;
        cin>>n;
        string s;
        cin>>s;
        s=" "+s;
        a[0]=1;
        for(int i=1;i<=n-1;i++)
        {
            if(s[i]=='=') a[i]=a[i-1];
            else if(s[i]=='<') a[i]=a[i-1]+1;
            else if(s[i]=='>')
            {
                a[i]=1;
                if(a[i-1]==1) a[i]=0;
            }
            if(a[i]<=0)
            {
                a[i]=1;
                int j=i;
                while(j>=1)
                {
                    if(s[j]=='>'&&a[j-1]<(a[j]+1)) a[j-1]=a[j]+1;
                    else if(s[j]=='=') a[j-1]=a[j];
                    else break;
                    j--;
                }
            }
        }
        for(int i=0;i<=n-1;i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
        s.clear();
    }
    return 0;
}

标签:周赛,typedef,ABC,const,LL,cin,long,76,tie
From: https://www.cnblogs.com/Vivian-0918/p/16866718.html

相关文章

  • OJ周赛第二场——排名
    排名 问题描述 有一个n个人的班级。你知道每个人的成绩,需要输出每个人的排名。 输入 第一行一个整数n。(1≤n≤10^5)第二行n个数,表示每个人的成绩c。(1......
  • OJ周赛第三场——最大和数列
    最大和数列 问题描述 给定一个长为m的序列b你需要构造出一个序列A满足:对于所有1≤i≤m,i在A中出现了bi次定义f(A) 的值如下:求满足条件的 f(A)的最大......
  • OJ周赛第二场——简单问题
    简单问题 问题描述 给定一个正整数n,你需要找出最小的整数k,使得对于大小为k的集合{1,2,⋯,n}的任何子集T,存在两个不同的整数u,v∈T,u是v的一个因子。 输入 ......
  • OJ周赛第二场——逆序对
    逆序对 问题描述 给你一个长度为n的排列的置换p(长度为n的排列的置换的定义为:对于排列1,2,3....n,你可以多次交换两个数后的序列。比如(1,5,4,2,3)是一个排列的置换,(3,2......
  • 计算机等级考试二级C语言上机题集(第76~80套)
    第76套1.程序填空题给定程序中,函数fun的功能是:找出100~999之间(含100和999)所有整数中各位上数字之和为x(x为一正整数)的整数,然后输出;符合条件的整数个数作为函数值返回。例......
  • lc 第318场周赛
    第一次参加我激动的心颤抖的手勉勉强强提交了第一题磕磕绊绊到达并最终倒在了第二题>-<[6229.对数组执行操作]classSolution{public:vector<int>applyO......
  • pat春季模拟考试+acwing第76周赛+AT276
    pat:模考58分,相较夏季赛差了不少1.模拟给定一个字符串,要求按照得分点和失分点进行模拟,求最后得分即可模拟比较难写参考小柳学渣大神的代码,大神码风和思路都很好1#i......
  • 题解 [ABC259Ex] Yet Another Path Counting
    首先,每种颜色互不干扰,因此考虑对每种颜色统计答案。有两种解法:枚举起始格子\((x,y)\)和结尾格子\((z,w)\),由组合数易知共有\(\binom{z-x+w-y}{z-x}\)种路径。时间......
  • LeeCode 318周赛复盘
    T1:对数组执行操作思路:模拟publicint[]applyOperations(int[]nums){intn=nums.length;for(inti=0;i<n-1;++i){if(nums[i]==nums[i+1......
  • ABC276
    ABC276tasks\(\color{Green}{★}\)表示赛时做出。\(\color{Yellow}{★}\)表示赛后已补。\(\color{Red}{★}\)表示\(\text{Tobesolved}\)。Contestrk:708th......