F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Engineer Assignment

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1773    Accepted Submission(s): 614


Problem Description
In Google, there are many experts of different areas. For example, MapReduce experts, Bigtable experts, SQL experts, etc. Directors need to properly assign experts to various projects in order to make the projects going smoothly.
There are N projects owned by a director. For the $i^{th}$ project, it needs $C_i$ different areas of experts, $a_{i,0}, a_{i,1}, ¡¤ ¡¤ ¡¤ , a_{i,C_i-1}$ respective. There are M engineers reporting to the director. For the $i^{th}$ engineer, he is an expert of $D_i$ different areas, $b_{i,0}, b_{i,1}, ... , b_{i,D_i-1}.$
Each engineer can only be assigned to one project and the director can assign several engineers to a project. A project can only be finished successfully if the engineers expert areas covers the project areas, which means, for each necessary area of the project, there is at least one engineer
masters it.
The director wants to know how many projects can be successfully finished.
 

Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line consisting of 2 integers, N the number of projects and M the number of engineers. Then N lines follow. The $i^{th}$ line containing the information of the $i^{th}$ project starts
with an integer $C_i$ then $C_i$ integers follow, $a_{i,0}, a_{i,1}, ... , a_{i,C_i-1}$ representing the expert areas needed for the $i^{th}$ project. Then another M lines follow. The $i_{th}$ line containing the information of the $i^{th}$ engineer starts with an integer $D_i$ then $D_i$ integers follow, $b_{i,0}, b_{i,1}, ... , b_{i,D_i-1}$ representing the expert areas mastered by $i^{th}$ engineer.
 

Output
For each test case, output one line containing ¡°Case #x: y¡±, where x is the test case number (starting from 1) and y is the maximum number of projects can be successfully finished.

limits


$\bullet 1 ¡Ü T ¡Ü 100.$
$\bullet 1 ¡Ü N, M ¡Ü 10.$
$\bullet 1 ¡Ü C_i ¡Ü 3.$
$\bullet 1 ¡Ü D_i ¡Ü 2.$
$\bullet 1 ¡Ü a_{i,j} , b_{i,j} ¡Ü 100.$
 

Sample Input
1 3 4 3 40 77 64 3 10 40 20 3 40 20 77 2 40 77 2 77 64 2 40 10 2 20 77
 

Sample Output
Case #1: 2
 

Hint

For the first test case, there are 3 projects and 4 engineers. One of the optimal solution is to assign the first(40 77) and second engineer(77 64) to project 1, which could cover the necessary areas 40, 77, 64. Assign the third(40 10) and forth(20 77) engineer to project 2, which could cover the necessary areas 10, 40, 20. There are other solutions, but none of them can finish all 3 projects.
So the answer is 2.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 09:09:53, Gzip enabled