#include #include typedef struct { char jmeno[35]; int pocRoli; int *role; } THerec; typedef struct { char nazev[35]; int muzeHrat; } TRole; THerec *herec; TRole *role; int najdiHerce(const char *jmeno, int max) { int i = 0; while (i < max && strcmp(herec[i].jmeno, jmeno) != 0) { i++; } if (i == max) i = -1; return(i); } int najdiRoli(const char *nazev, int max) { int i = 0; while (i < max && strcmp(role[i].nazev, nazev) != 0) { i++; } if (i == max) i = -1; return(i); } void pracuj(void) { int pocR, pocH, pocP; int i, j, idx, ch; char jm[35], na[35]; int nebude = 0; scanf("%d %d %d", &pocH, &pocR, &pocP); herec = (THerec *) malloc(pocH * sizeof(THerec)); for (i = 0; i < pocH; i++) { scanf("%s", herec[i].jmeno); herec[i].pocRoli = 0; } role = (TRole *) malloc(pocR * sizeof(TRole)); for (i = 0; i < pocR; i++) { scanf("%s", role[i].nazev); role[i].muzeHrat = 0; } /* Ctu, co muze herec hrat */ for (i = 0; i < pocH; i++) { scanf("%s %d", jm, &idx); ch = najdiHerce(jm, pocH); if (ch >= 0) { herec[ch].pocRoli = idx; herec[ch].role = malloc(idx * sizeof(int)); for (j = 0; j < idx; j++) { scanf("%s", na); herec[ch].role[j] = najdiRoli(na, pocR); if (herec[ch].role[j] >= 0) role[herec[ch].role[j]].muzeHrat++; } } } /* Ctu ty, kteri nemohou */ for (i = 0; i < pocP; i++) { scanf("%s", jm); ch = najdiHerce(jm, pocH); if (ch >= 0) { for (j = 0; j < herec[ch].pocRoli; j++) { role[herec[ch].role[j]].muzeHrat--; if (role[herec[ch].role[j]].muzeHrat <= 0) nebude = 1; } } } if (nebude == 1) { printf("Zatraceni demonstranti!\n"); } else { printf("Premiera bude!\n"); } for (i = 0; i < pocH; i++) { free((void *) herec[i].role); } free((void *) herec); free((void *) role); } int main(void) { int N; scanf("%d",&N); while(N) { pracuj(); N--; } return(0); }