text: To check if there are cycles . If yes , then they are not convertible . Else , they are convertible .
code: for ( auto it : mp ) { if ( it . first == it . second ) continue ; else { if ( find ( it . first ) == find ( it . second ) ) return false ; else join ( it . first , it . second ) ; } } return true ; }