Notice
Recent Posts
Recent Comments
Link
목록1765 (1)
나의 개발일지
문제 : https://www.acmicpc.net/problem/1765 🔑 union, find 입력으로 친구가 들어오면 서로 union 원수가 들어오면 양방향 그래프로 원수 관계를 생성 생성된 원수 관계 그래프를 이용해 "내 원수의 원수도 내 친구이다." 조건을 해결한다. 나 → 내 원수 → 내 원수의 원수 이렇게 거쳐서 (나, 내 원수의 원수)를 union from collections import defaultdict n = int(input()) m = int(input()) def union(a, b): x = find(a) y = find(b) parent[y] = x def find(x): if parent[x] == x: return x parent[x] = find(parent[x])..
백준
2024. 1. 17. 15:04