fork download
  1.  
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #define int long long
  7. #define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  8. #define endl "\n"
  9.  
  10. map<string, string> myMap;
  11. int idx = 1;
  12. int j = 1;
  13.  
  14. class TheLoai {
  15. public:
  16. string ma, name;
  17. friend istream& operator>>(istream& is, TheLoai& a) {
  18. a.ma = "TL";
  19. if (idx < 10) a.ma += "00" + to_string(idx);
  20. else if (idx < 100) a.ma += "0" + to_string(idx);
  21. else a.ma += to_string(idx);
  22. getline(is, a.name);
  23. myMap[a.ma] = a.name;
  24. ++idx;
  25. return is;
  26. }
  27. };
  28.  
  29. int cv(string& s) {
  30. int res = 0;
  31. for (char i : s) res = res * 10 + (i - '0');
  32. return res;
  33. }
  34.  
  35. class Phim {
  36. public:
  37. string ma, name, date, tap, tl, code;
  38. int ngay, thang, nam, soTap;
  39. friend istream& operator>>(istream& is, Phim& a) {
  40. a.code = "P";
  41. if (j < 10) a.code += "00" + to_string(j);
  42. else if (j < 100) a.code += "0" + to_string(j);
  43. else a.code += to_string(j);
  44. string s1, s2;
  45. getline(is, a.ma);
  46. a.tl = myMap[a.ma];
  47. getline(is, a.date);
  48. getline(is, a.name);
  49. getline(is, a.tap);
  50. stringstream ss2(a.date);
  51. getline(ss2, s2, '/');
  52. a.ngay = cv(s2);
  53. getline(ss2, s2, '/');
  54. a.thang = cv(s2);
  55. getline(ss2, s2, '/');
  56. a.nam = cv(s2);
  57. a.soTap = cv(a.tap);
  58. ++j;
  59. return is;
  60. }
  61. friend ostream& operator<<(ostream& os, Phim& a) {
  62. os << a.code << ' ' << a.tl << ' ' << a.date << ' ' << a.name << ' ' << a.tap << endl;
  63. return os;
  64. }
  65. };
  66.  
  67. bool cmp(Phim& a, Phim& b) {
  68. if (a.nam != b.nam) return a.nam < b.nam;
  69. if (a.thang != b.thang) return a.thang < b.thang;
  70. if (a.ngay != b.ngay) return a.ngay < b.ngay;
  71. if (a.name != b.name) return a.name < b.name;
  72. return a.soTap > b.soTap;
  73. }
  74.  
  75. void process(TheLoai mh[], int n, Phim a[], int m) {
  76. sort(a, a + m, cmp);
  77. }
  78.  
  79. void solve() {
  80. int n, m;
  81. cin >> n >> m;
  82. cin.ignore();
  83. TheLoai tl[100];
  84. Phim p[1000];
  85. for (int i = 0; i < n; i++) cin >> tl[i];
  86. for (int i = 0; i < m; i++) cin >> p[i];
  87. process(tl, n, p, m);
  88. for (int i = 0; i < m; i++) cout << p[i];
  89. }
  90.  
  91. signed main() {
  92. faster();
  93. int test = 1;
  94. // cin >> test;
  95. while (test--) solve();
  96. return 0;
  97. }
  98.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty