#P10774. BZOJ3563 DZY Loves Chinese

BZOJ3563 DZY Loves Chinese

Problem Description

Given an undirected graph G=(V,E)G = (V, E), there are qq queries. Each query gives an edge set, and you need to determine whether the graph is still connected after deleting this edge set. It is guaranteed that the size of the edge set does not exceed 1515. The queries are forced online.

Input Format

The first line contains two positive integers n,mn, m, denoting the number of vertices and edges in the graph.

The next mm lines each contain two positive integers ui,viu_i, v_i, denoting the ii-th edge.

Then one line contains QQ, denoting the number of queries.

The next QQ lines each start with an integer kk, followed by kk positive integers c1,c2,,ckc_1, c_2, \dots, c_k, representing an edge set of size kk, where cic_i is the index of an edge.

To enforce online processing, in each query, kk and c1,c2,,ckc_1, c_2, \dots, c_k must all be XORed with the number of previous answers that were connected.

Output Format

For each query, output Connected if the graph is connected; otherwise output Disconnected (without quotes).

5 10
2 1
3 2
4 2
5 1
5 3
4 1
4 3
5 2
3 1
5 4
5
1 1
2 7 0 3
6 0 7 4 6
1 2 7
0 5 0 2 13
Connected
Connected
Connected
Connected
Disconnected

Hint

Constraints: 1n1051\leq n\leq 10^5, 1m5×1051\leq m\leq 5\times 10^5, 1Q5×1041\leq Q\leq 5\times 10^4, 1k151\leq k\leq 15. It is guaranteed that there are no multiple edges or self-loops in the graph.

Translated by ChatGPT 5