• Codeforces Round #646 (Div. 2)


    题目传送门

    先放这,后面会补的

    A. Odd Selection

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int x, n, a[1010];
    int even, odd;
    void solve()
    {
        cin >> n >> x;
        odd = even = 0;
        rep(i, 1, n)
        {
            cin >> a[i];
            if (a[i] % 2)
                odd++;
            else
                even++;
        }
        int flag = 1;
        if (x == n && odd % 2 == 0)
            flag = 0;
        if (odd == 0)
            flag = 0;
        if ((x - 1) % 2 && even == 0)
            flag = 0;
        puts(flag ? "Yes" : "No");
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    B. Subsequence Hate

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    char s[1010];
    int n, dp[2][1010];
    int ans;
    void solve()
    {
        memset(s, 0, sizeof(s));
        cin >> s + 1;
        n = 0;
        for (int i = 1; s[i] != 0; i++)
        {
            n++;
            dp[0][i] = dp[0][i - 1];
            dp[1][i] = dp[1][i - 1];
            if (s[i] == '1')
                dp[0][i]++;
            if (s[i] == '0')
                dp[1][i]++;
        }
        ans = min(dp[0][n], dp[1][n]);
        for (int i = 1; s[i] != 0; i++)
        {
            ans = min(ans, dp[0][i] + dp[1][n] - dp[1][i]);
            ans = min(ans, dp[1][i] + dp[0][n] - dp[0][i]);
        }
        cout << ans << endl;
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    C. Game On Leaves

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int n, x;
    int u, v, cnt;
    void solve()
    {
        cin >> n >> x;
        cnt = 0;
        rep(i, 1, n - 1)
        {
            cin >> u >> v;
            if (u == x || v == x)
                cnt++;
        }
        if (cnt <= 1 || !(n & 1))
            puts("Ayush");
        else
            puts("Ashish");
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code
  • 相关阅读:
    常用的正则表达式
    vue多页面应用
    webpack + jquery + bootstrap 环境配置
    Goroutine的几个例子
    设置css通用字体
    简单的gulpfile.js参数配置
    1:时间戳转换成年月日函数,2:url截取参数方法,3:弹窗自定义方法 4:点击按钮加入购物车
    github上比较全的知识
    秒杀倒计时
    正则校验手机号码并获取手机验证码倒计时的实例
  • 原文地址:https://www.cnblogs.com/likunhong/p/13061366.html
Copyright © 2020-2023  润新知