eolymp
bolt
Try our new interface for solving problems
Məsələlər

Job or joy

Job or joy

How much time can you solve problems non-stop? Sometimes you want to rest, but now is just not the time. It is necessary to collect your thoughts in a fist and snatch victory from your rivals. This problem is designed to separate the merely good teams from the Champions, those who expect to get into the top ten from those who do not intend to take a place below the first. Since the number of enemies who are going to find the author of this tightly introduction to express what they think about him, grows, let’s get down to business. An undirected graph is given. Some queries follow. A query is a pair of vertices. For each query, find out if there exist at least three edge-disjoint paths from the first vertex to the second. \InputFile In first line there are two integers \textbf{n} and \textbf{k} (\textbf{1} ≤ \textbf{n}, \textbf{k} ≤ \textbf{100000}) --- number of vertices and edges in the graph. The next \textbf{k} lines describe edges by pair of connected vertices \textbf{a}, \textbf{b} (\textbf{1} ≤ \textbf{a}, \textbf{b} ≤ \textbf{n}). Edges connect different vertices and there is at most one edge between any two vertices. In the next line, there is number of queries \textbf{q} (\textbf{0} ≤ \textbf{q} ≤ \textbf{100000}). Each of the next \textbf{q} lines contains two integers \textbf{a}, \textbf{b} (\textbf{a 6 = b}, \textbf{1} ≤ \textbf{a}, \textbf{b} ≤ \textbf{n}) --- pair of vertices for which it is required to find out if there exist three distinct paths between them such that none of them share an edge. \OutputFile For each query, output a single line with either \textbf{Yes} if such three paths exist, or \textbf{No} otherwise.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
6 9
1 2
1 5
1 4
1 6
2 3
3 4
3 5
4 5
4 6
9
1 2
1 3
1 5
2 4
5 6
3 6
3 4
2 6
2 3
Çıxış verilənləri #1
No
Yes
Yes
No
No
No
Yes
No
No
Mənbə ЛКШ-2011 Севастополь 08.08.2011 д.1 Высшая лига