Q10919: Prerequisities?

// Accepted !!

#include <cstdlib>
#include <string.h>
#include <stdio.h>

int main()
{
    int k, M, c, r;
    char course[100][5];

    while(scanf("%d",&k))
    {
        if(k == 0)
            break;

        scanf("%d",&M);

        for(int i = 0; i < k; i++)
            scanf("%s",&course[i]);

        bool t = true;

        for(int i = 0; i < M; i++)
        {
            int count = 0;
            scanf("%d%d",&c,&r);
            for(int j = 0; j < c; j++)
            {
                char tmp[5];
                scanf("%s",&tmp);
                for(int x = 0; x < k; x++)
                {
                    if(strcmp(tmp,course[x]) == 0)
                        count++;
                }
            }
            if(count < r)
                t = false;
        }

        if(t)
            printf("yes\n");
        else
            printf("no\n");
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

Leave a Reply