#P10778. Edge Removal and Connectivity

    ID: 12816 Type: Default 1000ms 256MiB

Edge Removal and Connectivity

Edge Removal and Connectivity

Given an undirected graph \(G = (V, E)\) with \(n\) vertices and \(m\) edges, you are to answer \(q\) online queries. In each query, a set of at most 15 edges is specified to be removed from \(G\), and you need to determine whether the remaining graph is connected.

Note: The queries are processed online. That is, each query must be answered in the order they appear.

Input format: The first line contains three integers \(n, m, q\). The next \(m\) lines each contain two integers \(u\) and \(v\) that represent an undirected edge between vertices \(u\) and \(v\). Then, \(q\) queries follow. Each query begins with an integer \(k\) (\(0 \leq k \leq 15\)) representing the number of edges to remove, followed by \(k\) integers indicating the indices (1-indexed) of the edges to remove.

Output format: For each query, output "YES" if the graph remains connected after removing the given edges, and "NO" otherwise.

The formulas are written in \(\LaTeX\) format.

inputFormat

The input begins with three integers \(n\), \(m\), and \(q\):

n m q

Then follow \(m\) lines each with two integers \(u\) and \(v\) representing an undirected edge:

u1 v1
u2 v2
... 
um v_m

After that, there are \(q\) queries, each in the following format:

k e1 e2 ... e_k

where \(k\) (\(0\leq k\leq 15\)) is the number of edges to remove and each \(e_i\) is the 1-indexed edge number to remove.

outputFormat

For each query, output one line: "YES" if the graph remains connected after removing the specified edges, and "NO" otherwise.

sample

4 3 2
1 2
2 3
3 4
0
1 2
YES

NO

</p>