← 返回 pinterest 的题目列表Pin Connectivity (graph connectivity related to Pins)
类型:online_judge
You are given a connectivity graph of Pins: each Pin is a node, and edges represent a relationship/connection.
Implement a program that:
Takes n pins (0..n-1) and m undirected edges (u, v).
Answers q queries (a, b) asking whether a and b are in the same connected component.
Optional follow-ups:
How to support dynamically adding edges online?
How to output an actual path if needed?
Input format
Line 1: n m q
Next m lines: u v
Next q lines: a b
Output
For each query print true/false.