Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5.Social Network for TikTok Users Assuming TikTok currently has 105 users (which is definitely more), we can number them 1-105. It is known that
5.Social Network for TikTok Users Assuming TikTok currently has 105 users (which is definitely more), we can number them 1-105. It is known that there are m pairs of users that follow each other and each pair of users meeting the conditions can be represented by two numbers x and y: the user numbered x and the user numbered y follow each other. Furthermore, we can define a concept of "Social Network", for example: A and B follow each other, B and C follow each other. We can define A, B and C in the same social network, and we can then provide specific recommendation services for users A and C accordingly. With TikTok serving users globally and assuming that the number of countries served is T, we want to know how many users there are in the largest social network in each country. Input Description: Enter an integer T in the first line, followed by T sets of test data. For each set of test data: Enter an integer m in the first line, representing m pairs of relationships. Next m lines, enter two numbers x and y in each line, representing that the TikTok users numbered x and y are in the same socia network. 210 Output Description: For each set of data, output an answer representing the maximum number of users within a TikTok social network. Range of test data pairs: 1 T 10 Range of user numbers: 1 x, y 105 Range of user pairs: 1 m 2 * 106
Step by Step Solution
There are 3 Steps involved in it
Step: 1
class UnionFind def initself n selfparent listrangen selfsiz...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started