#C7009. Most Popular User
Most Popular User
Most Popular User
You are given N users and M bidirectional connections between them. Each connection contributes to the popularity of both users involved. The popularity of a user i can be expressed mathematically as:
$$P_i = \sum_{\text{connection } j \text{ incident to } i} 1 $$Your task is to determine the most popular user based on the number of connections. In the event that multiple users share the maximum popularity, output the user with the smallest user ID. If there are no connections (i.e., M = 0), then output None
.
inputFormat
The input is read from the standard input (stdin). The first line contains two integers N and M, where N is the number of users (numbered from 1 to N) and M is the number of connections. The following data consists of 2 * M integers representing the M connections. Each connection is given by two integers u and v indicating that there is a bidirectional connection between user u and user v.
outputFormat
The output is written to the standard output (stdout). It is a single line containing the ID of the most popular user. If no connections are provided (M = 0), output None
.
5 4 1 2 2 3 4 5 1 5
1