• 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
  • 相关阅读:
    第一本书 第七章(课后题)
    java基础小测试
    随笔1
    随笔
    日记 晴 2017.7.30
    自我介绍
    与或非逻辑运算符 与或非位运算符
    日记1 天气阴 阵雨
    归并排序的两个版本实现代码
    Winedt打开tex文件报错error reading的解决方案
  • 原文地址:https://www.cnblogs.com/likunhong/p/13061366.html
Copyright © 2020-2023  润新知