Canteen

来源:互联网 发布:dnf端口团队网盘 编辑:程序博客网 时间:2024/05/16 10:34

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 ith 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 nextK blocks — for the rest ones. The input ends with the line containing an integer M (0 ≤ M ≤ N).

Output

K lines — the ith 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

inputoutput
7RafinadKefirPastilaSmetanaChokoladeKljukvaImbir33RafinadKefirImbir1Rafinad3KefirKljukvaSmetana2ImbirSmetana3
YESNOMAYBE


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


原创粉丝点击