The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple(A+B+C+D)

Cooking Competition


Time Limit: 1 Second Memory Limit: 65536 KB


“Miss Kobayashi’s Dragon Maid” is a Japanese manga series written and illustrated by Coolkyoushinja. An anime television series produced by Kyoto Animation aired in Japan between January and April 2017.

In episode 8, two main characters, Kobayashi and Tohru, challenged each other to a cook-off to decide who would make a lunchbox for Kanna’s field trip. In order to decide who is the winner, they asked n people to taste their food, and changed their scores according to the feedback given by those people.

There are only four types of feedback. The types of feedback and the changes of score are given in the following table.

Type

Feedback

Score Change
(Kobayashi)

Score Change
(Tohru)

1 Kobayashi cooks better +1 0
2 Tohru cooks better 0 +1
3 Both of them are good at cooking +1 +1
4 Both of them are bad at cooking -1 -1

Given the types of the feedback of these n people, can you find out the winner of the cooking competition (given that the initial score of Kobayashi and Tohru are both 0)?

Input

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 100), indicating the number of test cases. For each test case:

The first line contains an integer n (1 ≤ n ≤ 20), its meaning is shown above.

The next line contains n integers a1, a2, … , an (1 ≤ ai ≤ 4), indicating the types of the feedback given by these n people.

Output

For each test case output one line. If Kobayashi gets a higher score, output “Kobayashi” (without the quotes). If Tohru gets a higher score, output “Tohru” (without the quotes). If Kobayashi’s score is equal to that of Tohru’s, output “Draw” (without the quotes).

Sample Input
2
3
1 2 1
2
3 4

Sample Output
Kobayashi
Draw

Hint

For the first test case, Kobayashi gets 1 + 0 + 1 = 2 points, while Tohru gets 0 + 1 + 0 = 1 point. So the winner is Kobayashi.

For the second test case, Kobayashi gets 1 - 1 = 0 point, while Tohru gets 1 - 1 = 0 point. So it’s a draw.
题意:n个人,每人给出评价(见图),问俩人最后谁赢。平局输出Draw。
题解:…….
代码:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#define LL long long
using namespace std;
const int N=1e5+10;
int main()
{
    int t,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        int a,b,c;
        a=b=0;
        while(n--)
        {
            scanf("%d",&c);
            if(c==1) a++;
            if(c==2) b++;
        }
        if(a>b) printf("Kobayashi\n");
        if(a==b) printf("Draw\n");
        if(a<b) printf("Tohru\n");
    }
}

Problem Preparation


Time Limit: 1 Second Memory Limit: 65536 KB


It’s time to prepare the problems for the 14th Zhejiang Provincial Collegiate Programming Contest! Almost all members of Zhejiang University programming contest problem setter team brainstorm and code day and night to catch the deadline, and empty bottles of Marjar Cola litter the floor almost everywhere!

To make matters worse, one of the team member fell ill just before the deadline. So you, a brilliant student, are found by the team leader Dai to help the team check the problems’ arrangement.

Now you are given the difficulty score of all problems. Dai introduces you the rules of the arrangement:
1. The number of problems should lie between 10 and 13 (both inclusive).
2. The difficulty scores of the easiest problems (that is to say, the problems with the smallest difficulty scores) should be equal to 1.
3. At least two problems should have their difficulty scores equal to 1.
4. After sorting the problems by their difficulty scores in ascending order, the absolute value of the difference of the difficulty scores between two neighboring problems should be no larger than 2. BUT, if one of the two neighboring problems is the hardest problem, there is no limitation about the difference of the difficulty scores between them. The hardest problem is the problem with the largest difficulty score. It’s guaranteed that there is exactly one hardest problem.

The team members have given you lots of possible arrangements. Please check whether these arrangements obey the rules or not.

Input

There are multiple test cases. The first line of the input is an integer T (1 ≤ T ≤ 104), indicating the number of test cases. Then T test cases follow.

The first line of each test case contains one integer n (1 ≤ n ≤ 100), indicating the number of problems.

The next line contains n integers s1, s2, … , sn (-1000 ≤ si ≤ 1000), indicating the difficulty score of each problem.

We kindly remind you that this problem contains large I/O file, so it’s recommended to use a faster I/O method. For example, you can use scanf/printf instead of cin/cout in C++.

Output

For each test case, output “Yes” (without the quotes) if the arrangement follows the rules, otherwise output “No” (without the quotes).

Sample Input
8
9
1 2 3 4 5 6 7 8 9
10
1 2 3 4 5 6 7 8 9 10
11
999 1 1 2 3 4 5 6 7 8 9
11
999 1 3 5 7 9 11 13 17 19 21
10
15 1 13 17 1 7 9 5 3 11
13
1 1 1 1 1 1 1 1 1 1 1 1 2
10
2 3 4 5 6 7 8 9 10 11
10
15 1 13 3 6 5 4 7 1 14

Sample Output
No
No
Yes
No
Yes
Yes
No
No

Hint

The first arrangement has 9 problems only, which violates the first rule.

Only one problem in the second and the fourth arrangement has a difficulty score of 1, which violates the third rule.

The easiest problem in the seventh arrangement is a problem with a difficulty score of 2, which violates the second rule.

After sorting the problems of the eighth arrangement by their difficulty scores in ascending order, we can get the sequence 1, 1, 3, 4, 5, 6, 7, 13, 14, 15. We can easily discover that |13 - 7| = 6 > 2. As the problem with a difficulty score of 13 is not the hardest problem (the hardest problem in this arrangement is the problem with a difficulty score of 15), it violates the fourth rule.
题意:对序列给出如下要求,问是否能满足。
1:题数【10,13】;
2:最小数为1.
3:1的出现不得少于两次。
4:相邻俩数绝对值之差小于2(最大值内组除外)
题解:。。。。
代码:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<cmath>
#include<string.h>
#define LL long long
using namespace std;
const int N=1e5+10;
int a[110];
int n;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        if(n<10||n>13)
        {
            printf("No\n");
            continue;
        }
        sort(a+1,a+1+n);
        if(a[1]!=1||a[2]!=1)
        {
            printf("No\n");
            continue;
        }
        bool flag=true;
        for(int i=2;i<n;i++)
        {
            if(abs(a[i]-a[i-1])>2)
            {
            flag=false;
            break;
            }
        }
        if(flag)
        printf("Yes\n");
        else
            printf("No\n");
    }
}

What Kind of Friends Are You?


Time Limit: 1 Second Memory Limit: 65536 KB


Japari Park is a large zoo home to extant species, endangered species, extinct species, cryptids and some legendary creatures. Due to a mysterious substance known as Sandstar, all the animals have become anthropomorphized into girls known as Friends.

Kaban is a young girl who finds herself in Japari Park with no memory of who she was or where she came from. Shy yet resourceful, she travels through Japari Park along with Serval to find out her identity while encountering more Friends along the way, and eventually discovers that she is a human.

However, Kaban soon finds that it’s also important to identify other Friends. Her friend, Serval, enlightens Kaban that she can use some questions whose expected answers are either “yes” or “no” to identitfy a kind of Friends.

To be more specific, there are n Friends need to be identified. Kaban will ask each of them q same questions and collect their answers. For each question, she also gets a full list of animals’ names that will give a “yes” answer to that question (and those animals who are not in the list will give a “no” answer to that question), so it’s possible to determine the name of a Friends by combining the answers and the lists together.

But the work is too heavy for Kaban. Can you help her to finish it?

Input

There are multiple test cases. The first line of the input is an integer T (1 ≤ T ≤ 100), indicating the number of test cases. Then T test cases follow.

The first line of each test case contains two integers n (1 ≤ n ≤ 100) and q (1 ≤ q ≤ 21), indicating the number of Friends need to be identified and the number of questions.

The next line contains an integer c (1 ≤ c ≤ 200) followed by c strings p1, p2, … , pc (1 ≤ |pi| ≤ 20), indicating all known names of Friends.

For the next q lines, the i-th line contains an integer mi (0 ≤ mi ≤ c) followed by mi strings si, 1, si, 2, … , si, mi (1 ≤ |si, j| ≤ 20), indicating the number of Friends and their names, who will give a “yes” answer to the i-th question. It’s guaranteed that all the names appear in the known names of Friends.

For the following n lines, the i-th line contains q integers ai, 1, ai, 2, … , ai, q (0 ≤ ai, j ≤ 1), indicating the answer (0 means “no”, and 1 means “yes”) to the j-th question given by the i-th Friends need to be identified.

It’s guaranteed that all the names in the input consist of only uppercase and lowercase English letters.

Output

For each test case output n lines. If Kaban can determine the name of the i-th Friends need to be identified, print the name on the i-th line. Otherwise, print “Let’s go to the library!!” (without quotes) on the i-th line instead.

Sample Input
2
3 4
5 Serval Raccoon Fennec Alpaca Moose
4 Serval Raccoon Alpaca Moose
1 Serval
1 Fennec
1 Serval
1 1 0 1
0 0 0 0
1 0 0 0
5 5
11 A B C D E F G H I J K
3 A B K
4 A B D E
5 A B K D E
10 A B K D E F G H I J
4 B D E K
0 0 1 1 1
1 0 1 0 1
1 1 1 1 1
0 0 1 0 1
1 0 1 1 1

Sample Output
Serval
Let’s go to the library!!
Let’s go to the library!!
Let’s go to the library!!
Let’s go to the library!!
B
Let’s go to the library!!
K

Hint

The explanation for the first sample test case is given as follows:

As Serval is the only known animal who gives a “yes” answer to the 1st, 2nd and 4th question, and gives a “no” answer to the 3rd question, we output “Serval” (without quotes) on the first line.

As no animal is known to give a “no” answer to all the questions, we output “Let’s go to the library!!” (without quotes) on the second line.

Both Alpaca and Moose give a “yes” answer to the 1st question, and a “no” answer to the 2nd, 3rd and 4th question. So we can’t determine the name of the third Friends need to be identified, and output “Let’s go to the library!!” (without quotes) on the third line.
题意:n个提问,q个问题。给出c个朋友的名字,对于每个问题,给出回答为是的人的名字。对于每个提问,给出这个人对于所有问题的回答,问能否确认唯一的这个人。能输出名字,不能输出“Let’s go to the library!!
”。
题解:模拟就行了。对于每道题,令它的贡献为2^i,这样通过贡献值就可确定人。
代码:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<cmath>
#include<map>
#include<string.h>
#define LL long long
using namespace std;
const int N=1e5+10;
map<string,int>mp;
map<int,string>mpp;
int r[220];
map<int,int>p;
int t,n,q,x;
char str[100];
void init()
{
    int x=1;
    for(int i=0; i<=22; i++)
    {
        p[i]=x;
        x*=2;
    }
}
int main()
{
    scanf("%d",&t);
    init();
    while(t--)
    {
        memset(r,0,sizeof(r));
        scanf("%d%d",&n,&q);
        int id=1;
        scanf("%d",&x);
        while(x--)
        {
            scanf("%s",str);
            mpp[id]=str;
            mp[str]=id++;
        }
        for(int i=0; i<q; i++)
        {
            scanf("%d",&x);
            while(x--)
            {
                scanf("%s",str);
                r[mp[str]]+=p[i];
            }
        }
        for(int i=1; i<=n; i++)
        {
            int sum=0;
            for(int j=0; j<q; j++)
            {
                scanf("%d",&x);
                if(x==1)sum+=p[j];
            }
            int ge=0;
            int v=0;
            for(int j=1; j<id; j++)
            {
                if(r[j]==sum)
                {
                    ge++;
                    v=j;
                }
            }
            if(ge==1) cout<<mpp[v]<<endl;
            else
            {
                printf("Let's go to the library!!\n");
            }

        }
    }
}

Let’s Chat


Time Limit: 1 Second Memory Limit: 65536 KB


ACM (ACMers’ Chatting Messenger) is a famous instant messaging software developed by Marjar Technology Company. To attract more users, Edward, the boss of Marjar Company, has recently added a new feature to the software. The new feature can be described as follows:

If two users, A and B, have been sending messages to each other on the last m consecutive days, the “friendship point” between them will be increased by 1 point.

More formally, if user A sent messages to user B on each day between the (i - m + 1)-th day and the i-th day (both inclusive), and user B also sent messages to user A on each day between the (i - m + 1)-th day and the i-th day (also both inclusive), the “friendship point” between A and B will be increased by 1 at the end of the i-th day.

Given the chatting logs of two users A and B during n consecutive days, what’s the number of the friendship points between them at the end of the n-th day (given that the initial friendship point between them is 0)?

Input

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 10), indicating the number of test cases. For each test case:

The first line contains 4 integers n (1 ≤ n ≤ 109), m (1 ≤ m ≤ n), x and y (1 ≤ x, y ≤ 100). The meanings of n and m are described above, while x indicates the number of chatting logs about the messages sent by A to B, and y indicates the number of chatting logs about the messages sent by B to A.

For the following x lines, the i-th line contains 2 integers la, i and ra, i (1 ≤ la, i ≤ ra, i ≤ n), indicating that A sent messages to B on each day between the la, i-th day and the ra, i-th day (both inclusive).

For the following y lines, the i-th line contains 2 integers lb, i and rb, i (1 ≤ lb, i ≤ rb, i ≤ n), indicating that B sent messages to A on each day between the lb, i-th day and the rb, i-th day (both inclusive).

It is guaranteed that for all 1 ≤ i < x, ra, i + 1 < la, i + 1 and for all 1 ≤ i < y, rb, i + 1 < lb, i + 1.

Output

For each test case, output one line containing one integer, indicating the number of friendship points between A and B at the end of the n-th day.

Sample Input
2
10 3 3 2
1 3
5 8
10 10
1 8
10 10
5 3 1 1
1 2
4 5

Sample Output
3
0

Hint

For the first test case, user A and user B send messages to each other on the 1st, 2nd, 3rd, 5th, 6th, 7th, 8th and 10th day. As m = 3, the friendship points between them will be increased by 1 at the end of the 3rd, 7th and 8th day. So the answer is 3.
题意:给出x,y两种区间,如果两个区间的交长度>=m,则贡献为len-m+1.问最后贡献问多少。
题解:刚开始看到区间长度为1e9.就不想做了,后来看到区间个数100。。暴力吧。
代码:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<cmath>
#include<map>
#include<string.h>
#define ll long long
using namespace std;
const int N=1e5+10;
int n,m,x,y;
struct node
{
   int  l,r;
}a[200];
int  lll,rr;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d%d",&n,&m,&x,&y);
        for(int i=1;i<=x;i++) scanf("%d%d",&a[i].l,&a[i].r);
        int  ans=0;
        for(int i=1;i<=y;i++)
        {
            scanf("%d%d",&lll,&rr);
            if(rr-lll+1<m) continue;
            for(int j=1;j<=x;j++)
            {
                if(a[j].r-a[j].l+1<m ) continue;
                ll L,R;
                R=min(rr,a[j].r);
                L=max(lll,a[j].l);
                if(R-L+1<m) continue;
                else
                    ans+=R-L+1-m+1;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值