#P1402. 酒店之王

    ID: 395 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>福建省历届夏令营网络流二分图最大流

酒店之王

Description

The owner of XX Hotel wants to become the "Hotel King." With this goal, the first step is to make the hotel more user-friendly. Many guests have their preferences for room color tones, sunlight, and favorite dishes. However, the hotel has only pp rooms, and there are only qq different dishes each day. Each room can accommodate only one guest, and each dish can be served to only one guest.

One day, nn guests arrived. Each guest stated which rooms they like and which dishes they like. Unfortunately, it may be impossible to satisfy all guests (a guest is satisfied if they both live in a liked room and eat a liked dish).

How should we assign rooms and dishes to maximize the number of satisfied guests?

Input Format

The first line contains three integers, representing n,p,qn, p, q.

Then follow nn lines, each containing pp integers, each being 00 or 11. On the ii-th line, the jj-th number indicates whether the ii-th person likes the jj-th room (11 means like, 00 means do not like).

Then follow nn lines, each containing qq integers, each being 00 or 11. On the ii-th line, the jj-th number indicates whether the ii-th person likes the jj-th dish (11 means like, 00 means do not like).

Output Format

Output the maximum number of satisfied guests.

2 2 2
1 0
1 0
1 1
1 1

1

Hint

Constraints

For all test points, 1n,p,q1001 \leq n, p, q \leq 100.

Translated by ChatGPT 5