fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5.  
  6. namespace rks
  7. {
  8. class Program
  9. {
  10. static StringBuilder result = new StringBuilder();
  11. static void Main(string[] args)
  12. {
  13. //Console.SetIn( new StringReader(Test1) ); // do usunięcia przed wysłaniem
  14. int t = int.Parse( Console.ReadLine() ); // t <= 5
  15. for( int i = 0; i < t; i++)
  16. {
  17. Solve1();
  18. Console.ReadLine();
  19. }
  20. Console.WriteLine( result );
  21. }
  22.  
  23. static void Solve1()
  24. {
  25. int n = int.Parse( Console.ReadLine() ); // n <= 100 000
  26. var sdict = new SortedDictionary<string, int>();
  27. for( int i = 0; i < n; i++ )
  28. {
  29. string line = Console.ReadLine();
  30. if( !sdict.TryAdd(line, 1) )
  31. sdict[line]++;
  32. }
  33. foreach( var kvp in sdict )
  34. //Console.WriteLine( $"{kvp.Key} {kvp.Value}" );
  35. result.AppendLine($"{kvp.Key} {kvp.Value}");
  36.  
  37. //Console.WriteLine();
  38. result.AppendLine();
  39. }
  40.  
  41.  
  42. const string Test1 = @"2
  43. 6
  44. 03 10103538 2222 1233 6160 0142
  45. 03 10103538 2222 1233 6160 0141
  46. 30 10103538 2222 1233 6160 0141
  47. 30 10103538 2222 1233 6160 0142
  48. 30 10103538 2222 1233 6160 0141
  49. 30 10103538 2222 1233 6160 0142
  50.  
  51. 5
  52. 30 10103538 2222 1233 6160 0144
  53. 30 10103538 2222 1233 6160 0142
  54. 30 10103538 2222 1233 6160 0145
  55. 30 10103538 2222 1233 6160 0146
  56. 30 10103538 2222 1233 6160 0143";
  57. }
  58. }
Success #stdin #stdout 0.03s 18488KB
stdin
2
6
03 10103538 2222 1233 6160 0142
03 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0142
30 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0142
 
5
30 10103538 2222 1233 6160 0144
30 10103538 2222 1233 6160 0142
30 10103538 2222 1233 6160 0145
30 10103538 2222 1233 6160 0146
30 10103538 2222 1233 6160 0143
stdout
03 10103538 2222 1233 6160 0141 1
03 10103538 2222 1233 6160 0142 1
30 10103538 2222 1233 6160 0141 2
30 10103538 2222 1233 6160 0142 2

30 10103538 2222 1233 6160 0142 1
30 10103538 2222 1233 6160 0143 1
30 10103538 2222 1233 6160 0144 1
30 10103538 2222 1233 6160 0145 1
30 10103538 2222 1233 6160 0146 1