V.I.P.
Time limit1sMemory limit1024 MB
Count the paths over active edges whose vertex weights strictly increase, answering each edge-flip query modulo 10^9+7.
- Level
Hard8 of 10
- Topics
- Graph, Dynamic programming, Divide and conquer
- Solved
- No attempts yet
Problem
The complete graph has vertices. There are edge activation records and vertex weights. Initially, every edge is inactive. Each of the records is one of the following, and every edge is activated at most once among the records.
- : Makes the edge connecting vertices and an active edge.
A path that visits vertices in increasing order of weight and does not use any inactive edge is called a V.I.P. (Very Important Path). For each query below, count the number of ***V.I.P.***s.
- : Flips the activation state of the edge connecting vertices and . Output the number of ***V.I.P.***s in the changed graph, then restore the original activation state.
Input
The first line contains the number of vertices , the number of active edges , and the number of queries , separated by spaces.
The second line contains the vertex weights , separated by spaces, where is the weight of vertex .
From line 3 to line , line contains the two endpoints and of the -th active edge, separated by a space.
From line to line , line contains the -th query and , separated by a space.
Output
For each query, output the number of ***V.I.P.***s. Since the answer can be very large, output it modulo .
Hint
In graph theory, a path is a sequence of adjacent vertices that visits each vertex at most once. A sequence of vertices with is a path if whenever , and for each there is an edge whose endpoints are and (with ).
An increasing sequence is a sequence of length that satisfies .