Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int i=0;i<astronaut.Length;i++){
- int lesser,greater;
- if(astronaut[i][0]<astronaut[i][1]){
- lesser = astronaut[i][0];
- greater = astronaut[i][1];
- }else{
- lesser = astronaut[i][1];
- greater = astronaut[i][0];
- }
- if(!allCountries.ContainsKey(lesser)) lesser = roots[lesser];
- if(!allCountries.ContainsKey(greater)) greater = roots[greater];
- allCountries[roots[lesser]].UnionWith(allCountries[roots[greater]]);
- foreach(int key in allCountries[greater]){
- roots[key] = roots[lesser];
- }
- if(roots[greater]!=greater) allCountries.Remove(greater);
- //PrintRoots(roots,n);
- //PrintCountries(allCountries);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement