Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
726 B
2
Indexable
Never
from collections import Counter 

parent  = {}

def union(node1, node2):
    root1, root2 = find(node1), find(node2)
    if root1 != root2:
        parent[root1] = root2
        
def find(node):
    if parent[node] == -1:
        return node
    parent[node] = find(parent[node])
    return parent[node]

t = int(input())
for _ in range(t):
    m = int(input())
    coordinates = []
    for _ in range(m):
        x, y = [int(item) for item in input().split(' ')]
        if parent[x] != -1:
            parent[x] = -1
        if parent[y] != -1:
            parent[y] = -1
        union(x,y)
        
value, count = Counter(parent.values()).most_common(1)[0]

print(count)