atcoder#ABC264E. [ABC264E] Blackout 2
[ABC264E] Blackout 2
Score : points
Problem Statement
A country has cities and power plants, which we collectively call places. The places are numbered , among which Places are the cities and Places are the power plants.
This country has power lines. Power Line () connects Place and Place bidirectionally. A city is said to be electrified if one can reach at least one of the power plants from the city using some power lines.
Now, events will happen. In the -th () event, Power Line breaks, making it unusable. Once a power line breaks, it remains broken in the succeeding events.
Find the number of electrified cities right after each events.
Constraints
- All values in input are integers.
- If , then or .
- are distinct.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the number of electrified cities right after the -th event.
5 5 10
2 3
4 10
5 10
6 9
2 9
4 8
1 7
3 6
8 10
1 8
6
3
5
8
10
2
7
4
4
2
2
2
1
Initially, all cities are electrified.
- The -st event breaks Power Line that connects Point and Point .- Now City is no longer electrified, while cities remain electrified.
- The -nd event breaks Power Line that connects Point and Point .
- The -rd event breaks Power Line that connects Point and Point .- Now Cities and are no longer electrified, while cities remain electrified.
- The -th event breaks Power Line that connects Point and Point .
- The -th event breaks Power Line that connects Point and Point .
- The -th event breaks Power Line that connects Point and Point .- Now City is no longer electrified, while city remains electrified.