#K2276. Centrality Scores
Centrality Scores
Centrality Scores
You are given n users labeled from 0 to n-1 and m friendship relations. Each friendship is represented as a pair of integers (a, b) indicating that user a and user b are friends. In this problem, each friendship contributes 1 to the centrality score of both involved users. Note that if a friendship pair is a self-connection (i.e. a = b), the user receives 2 points.
Your task is to compute and output the centrality score for each user. The scores should be printed in order from user 0 to user n-1, separated by a space.
The formula for the centrality score of user i can be represented as follows:
\( score(i) = \sum_{(a, b) \in F} \bigl[\mathbb{1}_{\{a=i\}} + \mathbb{1}_{\{b=i\}}\bigr] \)
where \(F\) is the set of all friendship pairs and \(\mathbb{1}_{\{condition\}}\) is the indicator function that equals 1 if the condition is true and 0 otherwise.
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), representing the number of users.
The second line contains an integer m (0 ≤ m ≤ 105), representing the number of friendship relations.
The following m lines each contain two integers a and b (0 ≤ a, b < n), denoting a friendship between user a and user b.
It is possible for a friendship to be a self-connection (i.e. a = b).
outputFormat
Output a single line containing n integers separated by spaces, where the i-th integer is the centrality score of user i.
## sample4
4
0 1
0 2
1 2
1 3
2 3 2 1