Problem T
Union-Find
Input
The first line of input consists of two integers
-
“=
” indicate that the sets containing and are joined -
“?
” is a query asking whether and belong to the same set
In both cases,
Output
For each query output a line containing “yes” if
Sample Input 1 | Sample Output 1 |
---|---|
10 4 ? 1 3 = 1 8 = 3 8 ? 1 3 |
no yes |
Sample Input 2 | Sample Output 2 |
---|---|
4 5 ? 0 0 = 0 1 = 1 2 = 0 2 ? 0 3 |
yes no |