#P11369. Dynamic Graph Path Query with Edge Color Toggling

    ID: 13445 Type: Default 1000ms 256MiB

Dynamic Graph Path Query with Edge Color Toggling

Dynamic Graph Path Query with Edge Color Toggling

You are given a directed graph with (n) nodes and (m) edges. The nodes are numbered (1,2,\dots,n) and the edges are numbered (1,2,\dots,m). Initially, every edge is colored black. You need to process (q) operations which can be one of the following two types:

  • 1 k: Toggle the color of the \(k\)-th edge (if it is black, it becomes white, and vice versa).
  • 2 u v: Query whether there is a path from node \(u\) to node \(v\) that uses only black edges.

Note that the operations are performed sequentially. Use \(\LaTeX\) formatting for all formulas, e.g. \(n\) is the number of nodes and \(m\) is the number of edges.

inputFormat

The input consists of multiple lines in the following format:

  1. The first line contains two integers (n) and (m).
  2. The next (m) lines each contain two integers (u) and (v), representing a directed edge from (u) to (v).
  3. The next line contains an integer (q), the number of operations.
  4. The following (q) lines each represent an operation in one of the two forms:
    • 1 k
    • 2 u v

outputFormat

For each operation of type 2, print a single line containing Yes if there exists a path from (u) to (v) using only black edges, and No otherwise.

sample

3 3
1 2
2 3
3 1
5
2 1 3
1 2
2 1 3
1 2
2 3 1
Yes

No Yes

</p>