Chores 1 - MarisaOJ: Marisa Online Judge

Chores 1

Time limit: 1000 ms
Memory limit: 256 MB
Today, Marisa visited Alice at her house. Alice was busy assigning chores to her collection of $n$ dolls, with $m$ chores in total. She knows that the $i^{th}$ doll can perform the $j^{th}$ chore, as indicated by the $q$ relations she has discovered. A doll can be assigned at most $1$ chore, and a chore can be assigned at most $1$ times. However, Alice does not know the maximum number of chores that can be completed. Therefore, she has asked Marisa for help, and Marisa is turning to you for assistance ### Input - The first line contains three integers $n,m,q$. - The next $q$ lines, each line contains two integers $i, j$, the $i^{th}$ doll can do the $j^{th}$ chore. ### Output - Print the maximum number of chores. ### Constraints - $1 \le n, m, q \le 10^5$. - $1 \le i \le n$. - $1 \le j \le m$. ### Example Input: ``` 4 5 6 1 1 1 2 1 5 2 1 3 4 4 3 ``` Output: ``` 4 ```
Topic
Graph
Flow
Rating 1400
Solution (0) Solution