fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define all(x) x.begin(), x.end()
  4. using namespace std;
  5. map<string, int> mp1, mp2;
  6. bool motcaigiday(string s) {
  7. for (int i = 1; i < s.size(); ++i) {
  8. if (s[i] != s[i - 1]) return false;
  9. }
  10. return true;
  11. }
  12. int main() {
  13. string daquy1, daquy2;
  14. int n;
  15. cin >> n;
  16. getline(cin, daquy1);
  17. for (int i = 0; i < daquy1.size(); ++i) {
  18. int k = 0;
  19. string xs = "";
  20. while (daquy1[i] >= '0' && daquy1[i] <= '9') {
  21. ++i;
  22. }
  23. while (daquy1[i] >= 'A' && daquy1[i] <= 'Z') {
  24. xs += daquy1[i];
  25. ++i;
  26. }
  27. while (daquy1[i] >= '0' && daquy1[i] <= '9') {
  28. k = k * 10 + (daquy1[i] - 48);
  29. ++i;
  30. }
  31. if (motcaigiday(xs)) {
  32. string a;
  33. a += xs[0];
  34. mp2[a] = k * (xs.size());
  35. }
  36. else {
  37. sort(all(xs));
  38. mp1[xs] = k;
  39. }
  40. }
  41. getline(cin, daquy2);
  42. for (int i = 0; i < daquy2.size(); ++i) {
  43. int k = 0;
  44. string xs = "";
  45. while (daquy2[i] >= '0' && daquy2[i] <= '9') {
  46. ++i;
  47. }
  48. while (daquy2[i] >= 'A' && daquy2[i] <= 'Z') {
  49. xs += daquy2[i];
  50. ++i;
  51. }
  52. while (daquy2[i] >= '0' && daquy2[i] <= '9') {
  53. k = k * 10 + (daquy2[i] - 48);
  54. ++i;
  55. }
  56. if (motcaigiday(xs)) {
  57. string a;
  58. a += xs[0];
  59. mp2[a] = k * (xs.size());
  60. }
  61. else {
  62. sort(all(xs));
  63. mp2[xs] = k;
  64. }
  65. }
  66.  
  67. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty