#K61197. Unique Followers Count
Unique Followers Count
Unique Followers Count
You are given a social network with n users labeled from 1 to n and m directed follow relationships. Each relationship is represented by two integers, a and b, indicating that user a follows user b.
Your task is to compute the number of unique followers for each user. Formally, for each user \(i\) (\(1 \le i \le n\)), you need to determine the value:
[ followers(i) = \left|{ a ;:; (a, i) \in F }\right| ]
where \(F\) denotes the set of follow pairs.
Print the results as n
integers separated by a space, where the i-th
integer corresponds to the number of unique followers of user i
.
inputFormat
The first line of input contains two space-separated integers n
and m
, representing the number of users and the number of follow relationships, respectively.
The next m
lines each contain two space-separated integers a
and b
, indicating that user a
follows user b
.
If m
is 0, there will be no additional lines.
outputFormat
Output a single line containing n
space-separated integers. The i-th
integer should represent the count of unique followers for user i
.
5 4
1 2
2 3
1 3
4 3
0 1 3 0 0