static void Main() { string[] lines = File.ReadAllLines("dsu.in"); int n = int.Parse(lines[0]); DSU dsu = new DSU(); for (int i = 1; i <= n; ++i) dsu.AddSingleItem(i); StreamWriter sw = new StreamWriter("dsu.out"); foreach (string s in lines.Skip(1)) { string[] parts = s.Split(' '); if (parts[0] == "union") { int a = int.Parse(parts[1]) - 1, b = int.Parse(parts[2]) - 1; dsu.Union(a,b); } else if (parts[0] == "get") { int a = int.Parse(parts[1]) - 1; DSU.DsuSet x = dsu.Get(a); sw.WriteLine("{0} {1} {2}", x.Min, x.Max, x.Count); } } sw.Close(); }