fork download
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <set>
  7. #include <limits>
  8. #include <vector>
  9. #include <queue>
  10. #include <map>
  11. #include <algorithm>
  12.  
  13. using namespace std;
  14.  
  15. int main(int argc, char **argv) {
  16. std::ios_base::sync_with_stdio(false);
  17. int T;
  18. cin >> T;
  19. for (int t = 0; t < T; ++t) {
  20. int n;
  21. cin >> n;
  22.  
  23. map<long long, map<long long, int> > m;
  24. long long p_0, p_1;
  25. long long c, b, a_0, a_1, a_2, a_3;
  26. const long long mult_0 = 1e+4;
  27. const long long mult_1 = 1e+8;
  28. const long long mult_2 = 1e+12;
  29.  
  30. for (int i = 0; i < n; ++i) {
  31. cin >> c >> b >> a_0 >> a_1 >> a_2 >> a_3;
  32. p_0 = c*mult_1 + b;
  33. p_1 = a_0*mult_2 + a_1*mult_1 + a_2*mult_0 + a_3;
  34.  
  35. map<long long, int>& mm = m[p_0];
  36. map<long long, int>::iterator it = mm.find(p_1);
  37. if (mm.end() == it) mm[p_1] = 1;
  38. else ++it->second;
  39. }
  40. long long tt;
  41. for (map<long long, map<long long, int> >::iterator it_0 = m.begin();
  42. it_0 != m.end(); ++it_0) {
  43. for (map<long long, int>::iterator it_1 = it_0->second.begin();
  44. it_1 != it_0->second.end(); ++it_1) {
  45. c = it_0->first/mult_1;
  46. b = it_0->first%mult_1;
  47. a_0 = it_1->first/mult_2;
  48. tt = it_1->first % mult_2;
  49. a_1 = tt/mult_1;
  50. tt %= mult_1;
  51. a_2 = tt /mult_0;
  52. a_3 = tt % mult_0;
  53. printf("%02lld %08lld %04lld %04lld %04lld %04lld %d\n",
  54. c, b, a_0, a_1, a_2, a_3, it_1->second);
  55. }
  56. }
  57. printf("\n");
  58. }
  59. }
Success #stdin #stdout 0s 3440KB
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