#P15597. [ICPC 2020 Jakarta R] Writing Tasks
[ICPC 2020 Jakarta R] Writing Tasks
题目描述
In , there are programming contests held in Indonesia, numbered from to . Each contest has zero or more tasks written for the contest. There are task authors who can write tasks for these contests, numbered from to . The task author only likes the set of contests , and only wants to write tasks for contests in . Each task author cannot write more than one task for the same contest.
There are also topics in programming contest tasks, numbered from to . For example, topic might be about graph tasks, topic might be about string tasks, and so on. Each task has exactly one topic. The task author is familiar with the set of topics , and only wants to write tasks about topics in . Each task cannot write more than one task about the same topic.
Additionally, each contest also has a syllabus. The contest syllabus contains the set of topics , and the topic for the tasks written for the contest must be in . Each contest cannot have more than one task for the same topic.
You are a programming contest enthusiast in Indonesia. Surprisingly, you observed the following:
- Each task author likes at most two contests. Similarly, each contest is liked by at most two task authors.
- Each task author is familiar with at most two topics. Similarly, each topic is familiarized by at most two task authors.
- Each contest has at most two topics in its syllabus. Similarly, each topic is present in at most two contest syllabuses.
You want to find the maximum total number of tasks that can be written across all contests.
输入格式
Input begins with a line containing three integers: () representing the number of task authors, contests, and topics, respectively.
The next lines each begins with an integer: () representing the number of contests that the task author likes, followed by integers: () representing the liked contests. It is guaranteed that the values in are distinct. It is also guaranteed that for all , the value only appears at most twice in .
The next lines each begins with an integer: () representing the number of topics that the task author is familiar with, followed by integers: () representing the familiarized topics. It is guaranteed that the values in are distinct. It is also guaranteed that for all , the value only appears at most twice in .
The next lines each begins with an integer: () representing the number of topics in the contest syllabus, followed by integers: () representing the topics in the syllabus. It is guaranteed that the values in are distinct. It is also guaranteed that for all , the value only appears at most twice in .
输出格式
Output in a line an integer representing the maximum total number of tasks that can be written across all contests.
2 3 2
2 1 2
2 2 3
1 1
1 1
1 1
1 1
1 2
2
提示
Explanation for the sample input/output #1
There are at most two tasks that can be written:
- The task author writes a task about the topic for the contest.
- The task author writes a task about the topic for the contest.
Note that the task author has written a task about the topic, thus they cannot write a task for the contest about the same topic.
This example can be illustrated by the following figure, with represents the task author, represents the contest, represents the topic, thick lines represent the first task, and the dashed lines represent the second task.
:::align{center}
:::