AcWing 第 88 场周赛 ABC

今天T2卡的我有点久(一开始的思考路线错了,手又冻的哆哆嗦嗦的,手速慢了哈哈(越来越菜了

https://www.acwing.com/activity/content/competition/problem_list/2840/

AcWing 4800. 下一个

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL x;
        cin>>x;
        string s=to_string(x);
        for(int i=x+1; ;i++)
        {
            string c=to_string(i);
            map<char,int> mp;
            bool flag=true;
            for(int j=0;j<c.size();j++)
            {
                mp[c[j]]++;
                if(mp[c[j]]>=2) flag=false;
            }
            if(flag==true)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
} 

AcWing 4801. 强连通图

这题的思考方向就是循环,正循环和负循环,注意无论中间如何变幻,但是四个角的顺序一定要按正或负循环顺序排列,才能够实现到达任意点。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        string s,c;
        cin>>s>>c;
        bool flag=true;
        //<><> v^v^v^
        if(s[0]=='<'&&s[n-1]=='>'&&c[0]=='v'&&c[m-1]=='^') ;
        else if(s[0]=='>'&&s[n-1]=='<'&&c[0]=='^'&&c[m-1]=='v') ;
        else flag=false;
        if(flag==false) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    return 0;
} 

AcWing 4802. 金明的假期

忘记在哪里写过了这个的原题,所以很快就写完了,
就是每天和前面一个具有关联性,然后及时更改状态即可

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        LL sum=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0) sum++;
            else if(a[i]==3)
            {
                if(a[i-1]==2) a[i]=1;
                else if(a[i-1]==1) a[i]=2;
            }
            else if(a[i]==1&&a[i-1]==1)
            {
                sum++;
                a[i]=0;
            }
            else if(a[i]==2&&a[i-1]==2)
            {
                sum++;
                a[i]=0;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}
posted @ 2023-01-28 21:40  高尔赛凡尔娟  阅读(4)  评论(0编辑  收藏  举报