#K76512. Assign Guards in Cities
Assign Guards in Cities
Assign Guards in Cities
In this problem, you are given (n) cities and (m) bidirectional roads. Each road connects two different cities. The task is to determine the minimum number of guards that should be assigned in each city based on the number of roads connected to it. In particular, if a city is connected by at least one road, it requires a number of guards equal to its degree (the number of roads incident to it); otherwise, it requires 0 guards. This can be formally described as follows: For each city (i), let (d_i) be the number of roads connected to it. You are to output an array (A) of length (n) such that (A_i = d_i) if (d_i > 0), and (A_i = 0) otherwise.
Note: The cities are numbered from 1 to (n).
inputFormat
The input is given via standard input (stdin) and has the following format:
n m
u1 v1
u2 v2
...
um vm
Here, the first line contains two integers (n) (the number of cities) and (m) (the number of roads). Each of the next (m) lines contains two integers (u) and (v), denoting that there is a road connecting city (u) and city (v).
outputFormat
Output a single line to standard output (stdout) containing (n) integers separated by spaces. The (i)-th integer represents the minimum number of guards required in city (i).## sample
1 0
0
</p>