#CSPJ2019D. 零件加工 (Parts Processing)
零件加工 (Parts Processing)
Description
Kaikai's factory is producing some kind of magical parts, and the production process of magical parts is, naturally, also magical. The factory has workers numbered from to . There are bidirectional conveyor belts between some workers. It is guaranteed that there is at most one conveyor belt between any two workers.
If worker wants to produce a part that is in the -th stage () of production, all workers who are directly connected to worker via a conveyor belt have to produce a part that is in stage (but worker doesn't need to produce a stage part).
If worker wants to produce a part that is in stage of production, all workers who are directly connected to worker via a conveyor belt have to provide worker with raw materials.
Xuan Xuan is worker . Given work orders, the -th work order is represented by two numbers and denoting that worker wants to produce a part in stage of production. Xuan Xuan wants to know whether he needs to provide raw materials to others for each work order. He knows that you are smart and can help him figure it out!
Input Format
The first line contains three positive integers and - the number of workers, the number of conveyor belts, and the number of work orders respectively.
Each of the next lines contains two integers and () denoting that there is a conveyor belt between the workers and .
Each of the next lines contains two positive integers and denoting that worker wants to produce a part in stage .
Output Format
For each work order print a single line containing Yes
if Xuan Xuan needs to provide raw materials for that work order, and No
otherwise.
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
For the first work order, worker 1 wants to produce a stage 1 part, so worker 2 needs to provide raw materials.
For the second work order, worker 2 wants to produce a stage 1 part, so workers 1 and 3 need to provide raw materials.
For the third work order, worker 3 wants to produce a stage 1 part, so worker 2 needs to provide raw materials.
For the fourth work order, worker 1 wants to produce a stage 2 part, so worker 2 needs to produce a stage 1 part, and workers 1 and 3 need to provide raw materials.
For the fifth work order, worker 2 wants to produce a stage 2 part, so workers 1 and 3 need to produce a stage 1 part, and both of them need worker 2 to provide raw materials.
For the sixth work order, worker 3 wants to produce a stage 2 part, so worker 2 needs to produce a stage 1 part, and workers 1 and 3 need to provide raw materials.
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
For the first work order, worker 1 wants to produce a stage 1 part, so workers 2 and 5 need to provide raw materials.
For the second work order, worker 1 wants to produce a stage 2 part, so workers 2 and 5 need to produce a stage 1 part, and workers 1, 3 and 4 need to provide raw materials.
For the third work order, worker 1 wants to produce a stage 3 part, so workers 2 and 5 need to produce a stage 2 part, workers 1, 3 and 4 need to produce a stage 1 part, and workers 2, 3, 4 and 5 need to provide raw materials.
For the fourth work order, worker 1 wants to produce a stage 4 part, so workers 2 and 5 need to produce a stage 3 part, workers 1, 3 and 4 need to produce a stage 2 part, workers 2, 3, 4 and 5 need to produce a stage 1 part, and all workers need to provide raw materials.
For the fifth work order, worker 1 wants to produce a stage 5 part, so workers 2 and 5 need to produce a stage 4 part, workers 1, 3 and 4 need to produce a stage 3 part, workers 2, 3, 4 and 5 need to produce a stage 2 part, all workers need to produce a stage 1 part, and all workers need to provide raw materials.
Constraints
There are a total of 20 tests.
Tests :
Tests :
Tests :
Tests :
Tests :