Processing math: 100%
DSU - MarisaOJ: Marisa Online Judge

DSU

Time limit: 1000 ms
Memory limit: 256 MB
Given a graph of n vertices and no edge. There are q queries of either form: - 1uv add an edge between u and v. - 2uv determine whether u and v are connected. ### Input - The first line contains 2 integers n,q. - The next q lines, each line contains 3 integers t,u,v, a query. ### Output - For each query of type 2, print YES if u and v are connected, otherwise print NO. ### Constraints - 1≤n,q≤105. - 1≤u,v≤n. ### Example Input: 65112113223156245 Output: YESNO