#P4334. [COI 2007] Policija

    ID: 3262 远端评测题 3000ms 63MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>搜索图论2007深度优先搜索,DFS割点COCI

[COI 2007] Policija

Description

To help capture criminals on the run, the police are introducing a new computer system. The area covered by the police contains NN cities and EE bidirectional roads connecting them. The cities are labelled 11 to NN.

The police often want to catch criminals trying to get from one city to another. Inspectors, looking at a map, try to determine where to set up barricades and roadblocks. The new computer system should answer the following two types of queries:

  1. Consider two cities AA and BB, and a road connecting cities G1G_1 and G2G_2. Can the criminals get from city AA to city BB if that one road is blocked and the criminals can't use it?

  2. Consider three cities A,BA, B and CC. Can the criminals get from city AA to city BB if the entire city CC is cut off and the criminals can't enter that city?

Write a program that implements the described system.

Input Format

The first line contains two integers NN and E (2N100000,1E500000)E\ (2 \le N \le 100\,000, 1 \le E \le 500\,000), the number of cities and roads.

Each of the following EE lines contains two distinct integers between 11 and NN – the labels of two cities connected by a road. There will be at most one road between any pair of cities.

The following line contains the integer Q (1Q300000)Q\ (1 \le Q \le 300\,000), the number of queries the system is being tested on.

Each of the following QQ lines contains either four or five integers. The first of these integers is the type of the query – 11 or 22.

If the query is of type 11, then the same line contains four more integers A,B,G1A, B, G_1 and G2G_2 as described earlier. AA and BB will be different. G1G_1 and G2G_2 will represent an existing road.

If the query is of type 22, then the same line contains three more integers A,BA, B and CC. A,BA, B and CC will be distinct integers.

The test data will be such that it is initially possible to get from each city to every other city.

Output Format

Output the answers to all QQ queries, one per line. The answer to a query can be yes or no.

13 15
1 2
2 3
3 5
2 4
4 6
2 6
1 4
1 7
7 8
7 9
7 10
8 11
8 12
9 12
12 13
5
1 5 13 1 2
1 6 2 1 4
1 13 6 7 8
2 13 6 7
2 13 6 8
yes
yes
yes
no
yes

Hint

Resource: Croatian Olympiad in Informatics 2007.