zoukankan      html  css  js  c++  java
  • Codeforces 570

    链接:https://codeforces.com/contest/570


    A - Elections - [水]

    AC代码:

    #include<bits/stdc++.h>
    using namespace std;
    int n,m;
    int cnt[105];
    int main()
    {
        cin>>n>>m;
        for(int i=1;i<=m;i++)
        {
            int mx=0, id=1;
            for(int j=1,x;j<=n;j++)
            {
                cin>>x;
                if(x>mx) mx=x, id=j;
            }
            cnt[id]++;
        }
    
        int id=1;
        for(int i=1;i<=n;i++)
        {
            if(cnt[i]>cnt[id]) id=i;
        }
        cout<<id<<endl;
    }

    B - Simple Game - [水]

    AC代码:

    #include<bits/stdc++.h>
    using namespace std;
    int n,m;
    int main()
    {
        cin>>n>>m;
        int l=m-1+1, r=n-m+1;
        if(l>=r) cout<<max(1,m-1)<<endl;
        else cout<<min(n,m+1)<<endl;
    }

    C - Replacement

    AC代码:

    #include<bits/stdc++.h>
    using namespace std;
    const int maxn=3e5+10;
    int n,m;
    char s[maxn];
    int check(int x,int y)
    {
        if(y<=1 || x>=n) return 0;
    
        if(s[x]=='.' && s[y]=='.') return 1;
        else return 0;
    }
    int main()
    {
        cin>>n>>m;
        scanf("%s",s+1);
    
        int cnt=0;
        for(int i=1;i<n;i++) cnt+=check(i,i+1);
        for(int i=1;i<=m;i++)
        {
            int p; char x[2];
            scanf("%d %s",&p,x);
            int del=check(p-1,p)+check(p,p+1);
            s[p]=x[0];
            int add=check(p-1,p)+check(p,p+1);
            cnt=cnt-del+add;
            printf("%d
    ",cnt);
        }
    }

    D - Tree Requests - [DFS序+二分]


    E - Pig and Palindromes - [滚动优化DP]

  • 相关阅读:
    Linux文件权限
    Linux命令
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/dilthey/p/10571543.html
Copyright © 2011-2022 走看看