UVa : 10919 (Prerequisites?)



// http://uva.onlinejudge.org/external/109/10919.html
// Runtime : 0.128s
// Tag : map, adhoc


// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define pi acos(-1.0)
#define N 1000000
#define LL unsigned long long
using namespace std;


int main ()
{
    int k;

    while ( scanf ("%d", &k) && k ) {
        int m;
        scanf ("%d", &m);

        map <string, bool> mapping;

        for ( int i = 0; i < k; i++) {
            char a [10]; scanf ("%s", a);
            mapping [a] = true;
        }

        int degree = true;

        for ( int i = 0; i < m; i++ ) {
            int n; scanf ("%d", &n);
            int c; scanf ("%d", &c);
            for ( int j = 0; j < n; j++ ) {
                char a [10]; scanf ("%s", a);
                if ( mapping [a] ) c--;
            }

            if ( c > 0 ) degree = false;
        }

        if ( degree ) printf ("yes\n");
        else printf ("no\n");
    }

	return 0;
}

// @END_OF_SOURCE_CODE
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s