fork download
  1. //----->|try=0; while(!success) try++;|<------
  2. //----->|Belief Yourself,Respect Yourself|<----
  3. //----->|Be Proud Of Yourself,You're Doing Your best|<-----
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. #define uniq(x) x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
  7. #define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr //Upper value search;
  8. #define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr //Lower value search;
  9. #define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
  10. #define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
  11. #define rep(i, n) for(int i = 0; i < n; ++i)
  12. #define REP(i, n) for(int i = 1; i <= n; ++i)
  13. #define rep1(i,start,n) for(int i=start;i<n;++i)
  14. #define PI acos(-1.0)//PI Calculation
  15. #define LL long long
  16. #define AND(a,b) ((a) & (b))
  17. #define OR(a,b) ((a)|(b))
  18. #define XOR(a,b) ((a) ^ (b))
  19. #define mp make_pair
  20. #define sqr(x) ((x)*(x))
  21. #define sqrt(x) sqrt(1.0*(x))
  22. #define INF_MAX 2147483647
  23. #define INF_MIN -2147483647
  24. #define MX 1000005
  25. #define MOD 1000000007
  26. template<typename T> T POW(T b,T p) //Pow calculation
  27. {
  28. T r=1;
  29. while(p)
  30. {
  31. if(p&1)r=(r*b);
  32. b=(b*b);
  33. p>>=1;
  34. }
  35. return r;
  36. }
  37.  
  38. template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
  39. {
  40. T r=1;
  41. while(p)
  42. {
  43. if(p&1)r=(r*b)%m;
  44. b=(b*b)%m;
  45. p>>=1;
  46. }
  47. return r;
  48. }
  49.  
  50. //||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
  51. int main()
  52. {
  53. //freopen("a.in", "r", stdin);
  54. //freopen("a.out", "w", stdout);
  55. int test,len1,len2,cnt,cnt1,cnt2,cnt3;
  56. string s1,s2,temp1,temp2,total[101],neg[101],pos[101],chng[101];
  57. cin>>test;
  58. while(test--)
  59. {
  60. cin>>s1>>s2;
  61. len1=s1.size();
  62. len2=s2.size();
  63.  
  64.  
  65.  
  66. cnt=0;
  67. map<string,int>key1;
  68. map<string,int>key2;
  69. map<string,string>value1;
  70. map<string,string>value2;
  71. //Old dictionary;
  72. //cout<<"Old dictionary"<<endl;
  73. for(int i=1;i<len1-1;i++)
  74. {
  75. temp1="";
  76. while(s1[i]!=':')
  77. {
  78. temp1+=s1[i];
  79. i++;
  80. }
  81. total[cnt++]=temp1;
  82. key1[temp1]=1;
  83. i++;
  84. temp2="";
  85. while(s1[i]!=',' && s1[i]!='}')
  86. {
  87. temp2+=s1[i];
  88. i++;
  89. }
  90. value1[temp1]=temp2;
  91.  
  92. //cout<<temp1<<" "<<value1[temp1]<<endl;
  93. }
  94.  
  95. //cout<<"New dictionary"<<endl;
  96. //New dictionary checking;
  97.  
  98.  
  99.  
  100. for(int j=1;j<len2-1;j++)
  101. {
  102. temp1="";
  103. while(s2[j]!=':')
  104. {
  105. temp1+=s2[j];
  106. j++;
  107. }
  108. key2[temp1]=1;
  109. if(key1[temp1]!=1) total[cnt++]=temp1;
  110. j++;
  111. temp2="";
  112. while(s2[j]!=',' && s2[j]!='}')
  113. {
  114. temp2+=s2[j];
  115. j++;
  116. }
  117. value2[temp1]=temp2;
  118. //cout<<temp1<<" "<<value2[temp1]<<endl;
  119. }
  120. /*for(int k=0;k<cnt;k++)
  121.   {
  122.   cout<<total[k]<<endl;
  123.   }*/
  124.  
  125.  
  126.  
  127. cnt1=0;
  128. cnt2=0;
  129. cnt3=0;
  130. for(int i=0;i<cnt;i++)
  131. {
  132. if(key1[total[i]]==1 && key2[total[i]]!=1) neg[cnt1++]=total[i];
  133. else if(key1[total[i]]!=1 && key2[total[i]]==1) pos[cnt2++]=total[i];
  134. else if(value1[total[i]]!=value2[total[i]]) chng[cnt3++]=total[i];
  135. }
  136. //sorting
  137. sort(neg,neg+cnt1);
  138. sort(pos,pos+cnt2);
  139. sort(chng,chng+cnt3);
  140.  
  141. if(!cnt1 && !cnt2 && !cnt3) cout<<"No changes"<<endl;
  142. else
  143. {
  144. //positive checking;
  145. if(cnt2)
  146. {
  147. cout<<"+"<<pos[0];
  148. for(int i=1;i<cnt2;i++)
  149. {
  150. cout<<","<<pos[i];
  151. }
  152. cout<<endl;
  153. }
  154.  
  155.  
  156. //negative checking;
  157. if(cnt1)
  158. {
  159. cout<<"-"<<neg[0];
  160. for(int i=1;i<cnt1;i++)
  161. {
  162. cout<<","<<neg[i];
  163. }
  164. cout<<endl;
  165. }
  166.  
  167. //change checking;
  168. if(cnt3)
  169. {
  170. cout<<"*"<<chng[0];
  171. for(int i=1;i<cnt3;i++)
  172. {
  173. cout<<","<<chng[i];
  174. }
  175. cout<<endl;
  176. }
  177.  
  178.  
  179. }
  180. cout<<endl;
  181.  
  182. }
  183. }
  184.  
Success #stdin #stdout 0s 3492KB
stdin
3
{a:3,b:4,c:10,f:6}
{a:3,c:5,d:10,ee:4}
{x:1,xyz:123456789123456789123456789}
{xyz:123456789123456789123456789,x:1}
{first:1,second:2,third:3}
{third:3,second:2}
stdout
+d,ee
-b,f
*c

No changes

-first