zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    【初学EXT】布局练习
    创建型模式总结(补充UML类图)
    数据库基本概念总结
    Word2010操作技巧总结
    VMWare虚拟机磁盘压缩和上网总结
    第一次用word2010发布文章到博客园记
    设计模式学习总结一原则及创建型模式
    为什么要开始写blog?
    Delphi异常处理总结
    设计模式总结之行为型模式
  • 原文地址:https://www.cnblogs.com/likunhong/p/13061366.html
Copyright © 2011-2022 走看看