#P1710. Subway Fare Increase Impact
Subway Fare Increase Impact
Subway Fare Increase Impact
In the city of Boai, there is a mature subway system modeled as a connected undirected graph with N stations and M bidirectional segments connecting two different stations. Originally, each segment costs 1 Boai dollar. In other words, the fare from station A to station B is equal to the number of segments on the chosen path, and students always choose a path that minimizes the number of segments (this minimum number is denoted by \(d[i]\) for station \(i\)).
Fanhua High School is located at station 1. Due to financial difficulties, the subway company plans to raise the fare on some segments. Each price raise changes the cost of that segment from 1 to 2; note that no segment is raised more than once. There are Q such raises, and they occur one after another.
After some raises, students know that if one of the segments on one of their originally shortest paths is raised, they can choose an alternative route using only segments whose current cost remains 1 in order to keep their total fare equal to the original optimum \(d[i]\). However, when for a given station there is no path from that station to station 1, consisting entirely of segments with cost 1 (i.e. not raised) and having exactly \(d[i]\) edges, then the students living near that station will become unhappy.
Your task is, for each raise, to compute how many stations (other than station 1, which is the school) become unhappy immediately after the raise.
Note: Only edges that lie on some shortest path (i.e. those satisfying \(d[u]=d[v]+1\) for some ordering of the endpoints) are relevant. When an edge is raised, it is removed from the "shortest path set". A station remains content if and only if, in the subgraph formed by the segments that have not been raised, there exists a path from that station to station 1 composed of exactly \(d[i]\) edges.
The input guarantees that the original subway network is connected.
inputFormat
The input begins with three integers N
, M
, and Q
(2 ≤ N ≤ 10^5
, 1 ≤ M ≤ 2×10^5
, 1 ≤ Q ≤ 2×10^5
). Following this are M
lines, each containing two integers u
and v
(1 ≤ u, v ≤ N
, u ≠ v
), representing an undirected segment between stations u
and v
.
Then follow Q
lines, each containing a single integer e
(1 ≤ e ≤ M
). The integer e
indicates that the e
-th segment (in the order of input) has its fare raised from 1 to 2 at that moment. Each segment is raised at most once.
outputFormat
Output Q
lines. The i
-th line should contain a single integer: the number of stations that become unhappy (i.e. from which there is no path to station 1 with total cost equal to the original number of segments) immediately after the i
-th raise.
sample
4 4 3
1 2
2 3
2 4
3 4
3
1
2
1
3
3
</p>