fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. using ll = long long;
  8. using ld = long double;
  9.  
  10. #define all(x) x.begin(),x.end()
  11. #define v(x) vector<x>
  12. #define nl '\n'
  13. #define fxd(x) fixed << setprecision(x)
  14. template<class t> using ordered_set = tree<t, null_type, less<t>, rb_tree_tag, tree_order_statistics_node_update>;
  15. template<class t> using ordered_multiset = tree<t, null_type, less_equal<t>, rb_tree_tag, tree_order_statistics_node_update>;
  16.  
  17. struct item
  18. {
  19. ll val;
  20. ll w;
  21. string type;
  22. ll date;
  23. string name;
  24. };
  25.  
  26. bool cmp(const item& a, const item& b)
  27. {
  28. if(a.val == b.val)
  29. {
  30. if(a.w == b.w)
  31. {
  32. if(a.type == b.type)
  33. {
  34. if(a.date == b.date)
  35. {
  36. return a.name < b.name;
  37. }
  38. else
  39. {
  40. return a.date < b.date;
  41. }
  42. }
  43. else
  44. {
  45. return a.type < b.type;
  46. }
  47. }
  48. else
  49. {
  50. return a.w < b.w;
  51. }
  52. }
  53. else
  54. {
  55. return a.val < b.val;
  56. }
  57. }
  58.  
  59.  
  60. int main()
  61. {
  62. ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  63. int n; cin >> n;
  64. vector<item> arr(n);
  65. for (int i = 0; i < n; i++)
  66. {
  67. cin >> arr[i].val >> arr[i].w >> arr[i].type >> arr[i].date >> arr[i].name;
  68. }
  69.  
  70. sort(arr.begin(),arr.end(),cmp);
  71. for (int i = 0; i < n; i++)
  72. {
  73. cout << arr[i].val << " " << arr[i].w << " " << arr[i].type << " " << arr[i].date << " " << arr[i].name << nl;
  74. }
  75.  
  76. }
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
Standard output is empty