Advertisement
HashZayed

rattle joint

May 20th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. for(int i=0;i<astronaut.Length;i++){
  2.             int lesser,greater;
  3.            
  4.             if(astronaut[i][0]<astronaut[i][1]){
  5.                 lesser = astronaut[i][0];
  6.                 greater = astronaut[i][1];
  7.             }else{
  8.                 lesser = astronaut[i][1];
  9.                 greater = astronaut[i][0];
  10.             }
  11.            
  12.             if(!allCountries.ContainsKey(lesser)) lesser = roots[lesser];
  13.             if(!allCountries.ContainsKey(greater)) greater = roots[greater];            
  14.  
  15.             allCountries[roots[lesser]].UnionWith(allCountries[roots[greater]]);
  16.             foreach(int key in allCountries[greater]){
  17.                 roots[key] = roots[lesser];
  18.             }
  19.             if(roots[greater]!=greater) allCountries.Remove(greater);
  20.             //PrintRoots(roots,n);
  21.             //PrintCountries(allCountries);
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement