fork download
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <map>
  4. using namespace std;
  5. int main() {
  6. int t;
  7. scanf("%d", &t);
  8. char OLD[300], NEW[300];
  9. while(t--) {
  10. scanf("%s %s", &OLD, &NEW);
  11. map<string, string> O, N;
  12. int i, idx;
  13. char key[300], val[300];
  14. for(i = 1; OLD[i]; i++) {
  15. idx = 0;
  16. while(OLD[i] != ':')
  17. key[idx++] = OLD[i++];
  18. key[idx] = '\0';
  19. idx = 0, i++;
  20. while(OLD[i] != ',' && OLD[i] != '}')
  21. val[idx++] = OLD[i++];
  22. val[idx] = '\0';
  23. O[key] = val;
  24. }
  25. for(i = 1; NEW[i]; i++) {
  26. idx = 0;
  27. while(NEW[i] != ':')
  28. key[idx++] = NEW[i++];
  29. key[idx] = '\0';
  30. idx = 0, i++;
  31. while(NEW[i] != ',' && NEW[i] != '}')
  32. val[idx++] = NEW[i++];
  33. val[idx] = '\0';
  34. N[key] = val;
  35. }
  36. int flag = 0, tot = 0;
  37. for(map<string, string>::iterator it = N.begin();
  38. it != N.end(); it++) {
  39. if(O.find(it->first) == O.end()) {
  40. if(!flag)
  41. printf("+");
  42. else
  43. printf(",");
  44. cout << it->first;
  45. flag = 1;
  46. }
  47. }
  48. if(flag) puts("");
  49. tot += flag, flag = 0;
  50. for(map<string, string>::iterator it = O.begin();
  51. it != O.end(); it++) {
  52. if(N.find(it->first) == N.end()) {
  53. if(!flag)
  54. printf("-");
  55. else
  56. printf(",");
  57. cout << it->first;
  58. flag = 1;
  59. }
  60. }
  61. if(flag) puts("");
  62. tot += flag, flag = 0;
  63. for(map<string, string>::iterator it = N.begin();
  64. it != N.end(); it++) {
  65. if(O.find(it->first) != O.end()) {
  66. if(it->second != O[it->first]) {
  67. if(!flag)
  68. printf("*");
  69. else
  70. printf(",");
  71. cout << it->first;
  72. flag = 1;
  73. }
  74. }
  75. }
  76. if(flag) puts("");
  77. tot += flag, flag = 0;
  78. if(!tot) puts("No changes");
  79. puts("");
  80. }
  81. return 0;
  82.  
  83. }
Runtime error #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Standard output is empty