#P5663. [CSP-J 2019] 加工零件
[CSP-J 2019] 加工零件
Description
Kaikai’s factory is producing a magical part in an orderly way, and of course the production process is also magical. There are workers in the factory, numbered from . Between some pairs of workers, there are two-way conveyor belts for transporting parts. It is guaranteed that there is at most one conveyor belt between any two workers.
If worker wants to produce a part processed to stage , then all workers that are directly connected to worker by a conveyor belt need to produce a part processed to stage (but worker himself/herself does not need to produce a stage part).
If worker wants to produce a part processed to stage , then all workers that are directly connected to worker by a conveyor belt need to provide worker with one raw material.
Xuanxuan is worker . Now work orders are given. The -th work order means that the worker numbered wants to produce a part at stage . For each work order, Xuanxuan wants to know whether he needs to provide raw materials for others. He knows that smart you can help him compute it.
Input Format
The first line contains three positive integers , , and , representing the number of workers, the number of conveyor belts, and the number of work orders.
The next lines each contain two positive integers and , indicating that there is a conveyor belt between worker and worker . It is guaranteed that .
The next lines each contain two positive integers and , indicating that worker wants to produce a part at stage .
Output Format
Output lines, each containing a string Yes or No. If producing according to the -th work order requires Xuanxuan (worker ) to provide raw materials, output Yes on the -th line; otherwise output No.
3 2 6
1 2
2 3
1 1
2 1
3 1
1 2
2 2
3 2
No
Yes
No
Yes
No
Yes
5 5 5
1 2
2 3
3 4
4 5
1 5
1 1
1 2
1 3
1 4
1 5
No
Yes
No
Yes
Yes
Hint
Sample 1 Explanation

If worker wants to produce a stage part, worker needs to provide raw materials.
If worker wants to produce a stage part, workers and need to provide raw materials.
If worker wants to produce a stage part, worker needs to provide raw materials.
If worker wants to produce a stage part, worker needs to produce a stage part, and workers and need to provide raw materials.
If worker wants to produce a stage part, workers and need to produce a stage part, and both of them need worker to provide raw materials.
If worker wants to produce a stage part, worker needs to produce a stage part, and workers and need to provide raw materials.
Sample 2 Explanation

If worker wants to produce a stage part, workers and need to provide raw materials.
If worker wants to produce a stage part, workers and need to produce a stage part, and workers need to provide raw materials.
If worker wants to produce a stage part, workers and need to produce a stage part, workers need to produce a stage part, and workers need to provide raw materials.
If worker wants to produce a stage part, workers and need to produce a stage part, workers need to produce a stage part, workers need to produce a stage part, and all workers need to provide raw materials.
If worker wants to produce a stage part, workers and need to produce a stage part, workers need to produce a stage part, workers need to produce a stage part, all workers need to produce a stage part, and all workers need to provide raw materials.
Constraints
There are test points in total.
For all test points, it is guaranteed that .
For test points , , , .
For test points , , , .
For test points , , .
For test points , , .
For test points , , .
Translated by ChatGPT 5
京公网安备 11011102002149号