ACM模版

心血来潮,参加了这么啥比赛,名字好长啊,只是参加了网赛,感觉还行,就是看不懂题~~~前两题过于简单,所以写在一起吧!

A-Cooking Competition

描述

题解

水题。

代码

#include <iostream>

using namespace std;

const int K[] = {
  0, 1, 0, 1, -1};
const int D[] = {
  0, 0, 1, 1, -1};

int main(int argc, const char * argv[])
{
    int T;
    cin >> T;

    int n, x, resK, resD;
    while (T--)
    {
        cin >> n;
        resK = resD = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> x;
            resK += K[x];
            resD += D[x];
        }
        if (resK > resD)
        {
            cout << "Kobayashi\n";
        }
        else if (resK < resD)
        {
            cout << "Tohru\n";
        }
        else
        {
            cout << "Draw\n";
        }
    }

    return 0;
}

B-Problem Preparation

描述

题解

这个题有一个暗坑,明明说难度最低为1,数据范围还 1000si1000 ,所以这里需要注意,如果出现负数,直接 NO。我就是这里没有翻译对,导致 WA 了好几遍。

代码

#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAXN = 110;

int s[MAXN];

int main(int argc, const char * argv[])
{
// freopen("/Users/zyj/Desktop/input.txt", "r", stdin);

    int T;
    scanf("%d", &T);

    int n;
    while (T--)
    {
        scanf("%d", &n);
// int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            scanf("%d", s + i);
// if (s[i] == 1)
// {
   
// cnt++;
// }
        }
        if (n < 10 || n > 13/* || cnt < 2*/)
        {
            printf("No\n");
            continue;
        }

        sort(s, s + n);

        // ???
        if (s[0] != 1 || s[0] != 1)
        {
            printf("No\n");
            continue;
        }

        int flag = 1;
        for (int i = 1; i < n; i++)
        {
            if (s[i] - s[i - 1] > 2 && s[i] != s[n - 1])
            {
                flag = 0;
                break;
            }
        }

        if (flag)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }

    return 0;
}