At_abc349 赛后总结

· · 个人记录

打了 4 道。\text{A,B,C,D},耗时 \text {23:53}\text{ rk 1481}。评价为菜就多练。

A

零和博弈,加的等于减的。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
    int xx=0;int f=1;
    char c = getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f = -1;
        c = getchar();
    }
    while(c>='0'&&c<='9'){
        xx = (xx<<1)+(xx<<3)+(c^48);
        c = getchar();
    }
    return xx*f;
}
#define maxn 200050
int n,a[maxn];
signed main(){
    n=read();
    int cnt=0;
    for(int i=1;i<n;i++)
        a[i]=read();
    for(int i=1;i<n;i++)
        cnt+=a[i];
    cout<<-cnt;
    return 0;
}

B

模拟即可。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
    int xx=0;int f=1;
    char c = getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f = -1;
        c = getchar();
    }
    while(c>='0'&&c<='9'){
        xx = (xx<<1)+(xx<<3)+(c^48);
        c = getchar();
    }
    return xx*f;
}
#define maxn 200050
int cnt1[maxn],cnt2[maxn];
string s;
signed main(){
    cin>>s;
    for(int i=0;i<s.length();i++)
        cnt1[s[i]-'a']++;
    for(int i=0;i<26;i++)
        if(cnt1[i]!=0) cnt2[cnt1[i]]++;
    for(int i=0;i<maxn;i++){
        if(cnt2[i]!=0&&cnt2[i]!=2){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

C

模拟即可。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
    int xx=0;int f=1;
    char c = getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f = -1;
        c = getchar();
    }
    while(c>='0'&&c<='9'){
        xx = (xx<<1)+(xx<<3)+(c^48);
        c = getchar();
    }
    return xx*f;
}
#define maxn 200050
string s1,s2;

int top=0;
signed main(){
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++)
        if(s1[i]-32==s2[top]) top++;
    if(top==3) cout<<"Yes";
    else if(top==2&&s2[2]=='X') cout<<"Yes";
    else cout<<"No";
    return 0;
}

D

贪心,一次能加多少就加多少。

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
inline int read(){
    int xx=0;int f=1;
    char c = getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f = -1;
        c = getchar();
    }
    while(c>='0'&&c<='9'){
        xx = (xx<<1)+(xx<<3)+(c^48);
        c = getchar();
    }
    return xx*f;
}
#define maxn 200050
int l,r;
int get(int x){
    int res=0;
    if(x==0) return 61;
    while(x){
        if(!(x&1)) res++;
        else break;
        x>>=1;
    }
    return res;
}
int a[maxn],b[maxn];
signed main(){
    l=read(),r=read();
    int x=l,cnt=0;
    while(x<r){
        cnt++;
        a[cnt]=x;
        int pos=get(x);
        while(x+(1ll<<pos)>r) pos--;
        b[cnt]=(x+=(1ll<<pos));
        //cout<<cnt<<' '<<x<<'\n';
        //system("pause");
    }
    cout<<cnt<<'\n';
    for(int i=1;i<=cnt;i++)
        cout<<a[i]<<' '<<b[i]<<'\n';
    return 0;
}