fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Demo
  6. {
  7. public static void Main()
  8. {
  9. int count = 100000;
  10. long s;
  11. s = DateTime.Now.Ticks;
  12. for(int x=0; x<count; x++)
  13. Test1();
  14. Console.WriteLine( (DateTime.Now.Ticks-s).ToString() );
  15. s = DateTime.Now.Ticks;
  16. for(int x=0; x<count; x++)
  17. Test2();
  18. Console.WriteLine( (DateTime.Now.Ticks-s).ToString() );
  19. }
  20. public static List<List<int>> Test1()
  21. {
  22. var list1 = new List<int>{1,2,3,4,5};
  23. var list2 = new List<int>{2,3};
  24. var list3 = new List<int>{3,2};
  25. var result = new List<List<int>>();
  26. list1.Sort();
  27. list2.Sort();
  28. list3.Sort();
  29. if(!result.Any(elm => elm.SequenceEqual(list1)))
  30. result.Add(list1);
  31. if(!result.Any(elm => elm.SequenceEqual(list2)))
  32. result.Add(list2);
  33. if(!result.Any(elm => elm.SequenceEqual(list3)))
  34. result.Add(list3);
  35. return result;
  36. }
  37. public static List<HashSet<int>> Test2()
  38. {
  39. var list1 = new List<int>{1,2,3,4,5};
  40. var list2 = new List<int>{2,3};
  41. var list3 = new List<int>{3,2};
  42. var result = new List<HashSet<int>>();
  43. result.Add(new HashSet<int>(list1));
  44. result.Add(new HashSet<int>(list2));
  45. result.Add(new HashSet<int>(list3));
  46. result = result.Distinct(HashSet<int>.CreateSetComparer()).ToList();
  47. return result;
  48. }
  49. }
Success #stdin #stdout 1.17s 34968KB
stdin
Standard input is empty
stdout
4439060
6938630