my solution is giving TLE for subtask 2 because for every type 3 query i am checking component is bipartite or not using DFS.i used weighted union-find with path compression but using only that for checking x & y connected or not. so, how to modify my solution so, i have not to perform whole bipartite check of component again-again for type 3 query.
link to solution
Once a set is blocked, it will always be block. Make an array and mark the set-element’th index as blocked for such arrangement. Then, use find_parent+Path compression to check quickly.