#703
Unrated
Reachable Pairs
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Consider an undirected graph with NN nodes labeled 1N1\dots N and MM edges (1N2105,0M41051\le N\le 2\cdot 10^5, 0\le M\le 4\cdot 10^5). You're given a binary string s1s2sNs_1s_2\dots s_N. At time tt for each t[1,N]t\in [1,N],

If st=0s_t=0, node tt is removed from the graph.If st=1s_t=1, node tt is removed from the graph, and edges are added between every pair of neighbors that node tt had just before removal.

Note that in both cases, when a node is removed from the graph all of its incident edges are removed as well.

Count the number of pairs of nodes that can reach each other via some sequence of edges just before each of timesteps 1N1\ldots N.

입력

The first line contains NN and MM.

The second line contains the bit string ss of length NN.

The next MM lines each contain two integers denoting an edge of the graph.

출력

NN lines, the number of pairs before each timestep.

예제 입력 1

3 2
111
1 2
1 3

예제 출력 1

3
1
0

예제 입력 2

3 2
000
1 2
1 3

예제 출력 2

3
0
0

예제 입력 3

7 8
1101101
6 2
1 2
2 3
6 3
1 3
1 7
4 5
2 7

예제 출력 3

11
7
4
2
1
1
0

점수

Inputs 4-6: N100N\le 100Inputs 7-8: All sis_i equal zero.Inputs 9-11: All sis_i equal one.Inputs 12-23: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.