luogu#P5227. [AHOI2013] 连通图

    ID: 4193 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2013线段树并查集各省省选安徽O2优化动态树 LCT

[AHOI2013] 连通图

Problem Description

Given an undirected connected graph and several small sets, each set contains some edges. For each set, you need to determine whether the graph remains connected after deleting the edges in this set. Queries for different sets are independent of each other.

A graph is defined to be connected if and only if for any two vertices, there exists a path connecting them.

Input Format

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

The next mm lines each contain two integers u,vu,v, meaning this edge connects vertices u,vu,v. The edge number of the line i+1i+1 is ii. It is guaranteed that there are no multiple edges or self-loops.

The next line contains an integer kk, denoting the number of sets.

The next kk lines each describe a set. The first number in each line is cc, the number of edges in the set, followed by cc numbers representing the edges in the set.

Output Format

For each set, output one line indicating whether the graph is connected after removing the edges in the set. If it is connected, output Connected; otherwise, output Disconnected.

4 5
1 2
2 3
3 4
4 1
2 4
3
1 5
2 2 3
2 1 2
Connected
Disconnected
Connected

Hint

1  n,k  1051~\leq~n,k~\leq~10^51  m  2 × 1051~\leq~m~\leq~2~\times~10^51  c  41~\leq~c~\leq~4

Translated by ChatGPT 5