Here is my solution to SPOJ Problem CHAIN : https://ideone.com/Egu19B
My solution involves maintaining 3 arrays, for containing the root node of each disjoint set as well as the root nodes of predator and prey of that disjoint set.
The problem : http://www.spoj.com/problems/CHAIN/
Thanks!