409233: GYM103463 M Rikka with Random Graph

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. Rikka with Random Graphtime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Hello everyone! I am your old friend Rikka. Welcome to Hangzhou Normal U. This is an interesting problem, which is problem about the Graph. I promise you all that this should be easiest problem for most people.

A random graph, or a random directed graph, is a graph which edges generated by randomly.

In this problem, we constructed a directed graph by randomly, you need to design a special data structure to support the following operations:

  • $$$u \; v$$$, query weather point $$$u$$$ can reach point $$$v$$$ through some edges.

If you are Candidate Master or Master or Grandmaster or Legendary Grandmaster or high level title in Programming competition, you will find that this problem is very easy to solve. Even this problem can be solved on any category of graph. Don't even care of this graph is randomly generated.

So in order to reflect your programming ability, you need to answer these queries online.

To decrease the size of the input, Rikka provides an directed graph via a random number generator with given random seeds , denoted by two integers $$$k_1$$$ and $$$k_2$$$, Supposing the number of vertices and edges in the graph are $$$n$$$ and $$$m$$$ respectively, the following code in C++ tells you how to generate the graph and store the $$$i$$$-th directed edge between the vertex $$$u[i]$$$ and $$$v[i]$$$ in corresponding arrays. You can use the code directly in your submissions.

Input

The first line contains $$$5$$$ integers, $$$n(2 \leq n \leq 10^5)$$$, $$$m(1 \leq m \leq \min(10^5, n \cdot (n - 1)))$$$, $$$q(1 \leq q \leq 10^5)$$$, $$$k_1, k_2(1 \leq k_1, k_2 \leq 10^9)$$$. Denoting the number of points, the number of edges, the number of queries, and the random seeds.

It is guaranteed that $$$k_1$$$ and $$$k_2$$$ are chosen randomly except for the sample.

Since the graph is randomly generated, it may contains self-loop or multiple edges.

In the next $$$q$$$ lines, each line contains two integers $$$u$$$ and $$$v(1 \leq u, v \leq n, u \neq v)$$$, representing query weather point $$$u$$$ can reach $$$v$$$ through some edges.

What you need to pay attention to is, you need to answer these queries online, so these queries will not be given to you at the beginning.

Output

For each queries, you need output "Yes"(without quotes) if $$$u$$$ can reach $$$v$$$ through some edges, or output "No"(without quotes).

Interaction

Initially, you will get the $$$n, m, q, k_1, k_2$$$ and the first queries.

You need to answer the $$$i$$$-th queries correctly before the $$$(i + 1)$$$-th queries will be given to you.

If your answer is legal, Jury will return the next querires to you or terminate the program if the answer is last answer.

If Jury return $$$-1$$$ instead of a next queries, that means you made an invalid answer.

Exit immediately after receiving $$$-1$$$ and you will see wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a answer, do not forget to output end of line and flush the output. Otherwise, you will get idleness limit exceeded. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • See the documentation for other languages.
ExamplesInput
10 90 3 123456789 987654321
1 2
2 1
10 9
Output
No
No
Yes
Input
2 1 1 123456789 987654321
1 2
Output
No

加入题单

上一题 下一题 算法标签: