|
||||||||||
FreeOpenTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 657 Accepted Submission(s): 136 Problem Description FreeOpen is an organization which arranges blind data for girls and boys. The moral of that name is ˇ°Open your free mind to find your other halfˇ±. FreeOpen use a pet to make a match to a girl and a boy. FreeOpen believe that if a girl and a boy like each other and they like the same pet, they will be happy when they are living together with that pet. There are n boys, m girls and k pets. FreeOpen want know the maximum matches. Each match consists of one girl, one boy and one pet, and each girl, boy or pet can only be in one single match. Input The first line consists of an integer T, indicating the number of test cases. The first line of each case consists of three integers G, B, P, indicating the number of girls, the number of boys and the number of pets. The next G * B matrix indicates whether a girl and a boy like each other. The i-th girl and j-th boy like each other if and only if Matrix (i, j) = 1; the next G * P matrix indicates whether a girl likes a pet and the next B * P matrix indicates whether a boy likes a pet. Output Output the maximum matches on a single line for each test case. Constrains 0 < T <= 10 0 < G, B, P <= 20 0 < G + B + P <= 60 Sample Input
Sample Output
Source | ||||||||||
|