Canteen

14 篇文章 0 订阅

1350. Canteen

Time limit: 1.0 second
Memory limit: 64 MB
It’s dangerous to eat in a canteen — you may be poisoned by a not fresh food. One may fall into a coma because of the canteen’s chicken and the other feels OK. And vice versa. The food is cooked from  M different food stuffs. There are  N different food stuffs in the menu but not all of them are at the distribution. Assume that  K + 1 students eat the food and we know for each student what products may poison him. The first student eats and he is not poisoned. How the dinner affect on the other students?

Input

The first line contains an integer  N (1 ≤  N ≤ 100). The next  N lines contain the food stuffs names — non-empty sequences of Latin letters and digits with length not more than 40 symbols. Then there is a number  K (1 ≤  K ≤ 100) and  K + 1 blocks describing the menu food stuffs dangerous for the canteen visitors afterwards. The  i th block starts with a line with an integer  Ni — an amount of dangerous food stuffs and then there are  Ni lines with the names of those dangerous stuffs (0 ≤  Ni ≤  N). The first block describes the food stuffs dangerous for the first student, the next K blocks — for the rest ones. The input ends with the line containing an integer  M (0 ≤  M ≤  N).

Output

K lines — the  i th line should contain:
  • YES, if the dinner is harmless for the (i + 1)st student,
  • NO, if among the food stuffs there is a dangerous one for the (i + 1)st student,
  • MAYBE, if there may be different situations under the given conditions.

Sample

input output
7
Rafinad
Kefir
Pastila
Smetana
Chokolade
Kljukva
Imbir
3
3
Rafinad
Kefir
Imbir
1
Rafinad
3
Kefir
Kljukva
Smetana
2
Imbir
Smetana
3
YES
NO
MAYBE


/**
这题……好折磨人……
    翻译不难,但是难弄懂……
    其实是这样的,第一个人吃的全是好的吃了good种;有m种食物是不好的,那还会有n-m-good种是好的,但是并不知道是哪几种;
    因此,
    如果某个同学吃的绝对不会中毒,那他吃的就是第一个人吃的几种之一或其中的几种;
    如果,某个同学还吃了第一个同学吃的之外的,如果,之外的数量(就是除去good那几种)超过(n-m-good)种,
         那就不幸了,他肯定吃了有毒的;
         否则,就是不确定的情况,因为,不能确定剩下的是不是全部属于(n-m-good)种无毒的……
    
    补脑题= =!
**/
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

#define maxn 110
int n;
char s[maxn][maxn];
int k;
int m,good;
char student[maxn][maxn][30];
int l[maxn];
int Find(char st[])
{
    for(int i=0; i<good; i++)
        if(strcmp(st,s[i])==0)
        return 1;
    return 0;
}

int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
            scanf("%s",s[0]);
        scanf("%d",&k);
        scanf("%d",&good);
        for(int i=0; i<good; i++)
            scanf("%s",s[i]);
        for(int i=0; i<k; i++)
        {
            scanf("%d",&l[i]);
            for(int j=0; j<l[i]; j++)
                scanf("%s",student[i][j]);
        }
        scanf("%d",&m);
        n-=good;
        n-=m;
        for(int i=0; i<k; i++)
        {
            int L=l[i];
            for(int j=0; j<l[i]; j++)
               L-=Find(student[i][j]);
            if(L==0)
                puts("YES");
            else if(L>n)
                puts("NO");
            else
                puts("MAYBE");
        }
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值