Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <cctype>
- #include <cstdlib>
- #include <climits>
- #include <ctime>
- #include <istream>
- #include <ostream>
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <numeric>
- #include <fstream>
- #include <sstream>
- #include <map>
- #include <set>
- #include <list>
- #include <stack>
- #include <queue>
- #include <deque>
- #include <limits>
- #include <bitset>
- #include <iterator>
- #include <utility>
- #include <functional>
- #include <tr1/unordered_map>
- #define vinf (1 << 28)
- #define inf ((~0U) >> (1))
- #define pi (2.0 * acos(0.0))
- #define lowbit(x) ((x) & (-(x)))
- #define sine(x) (sin(radians(x)))
- #define cosine(x) (cos(radians(x)))
- #define tangent(x) (tan(radians(x)))
- #define arcsine(x) (degrees((asin(x))))
- #define arccosine(x) (degrees((acos(x))))
- #define arctangent(x) (degrees((atan(x))))
- #define clr(ar) (memset(ar, 0, sizeof(ar)))
- #define radians(x) (((1.0 * x * pi) / 180.0))
- #define degrees(x) (((x * 180.0) / (1.0 * pi)))
- #define read() (freopen("lol.txt", "r+", stdin))
- #define write() (freopen("lol.txt", "w+", stdout))
- #define dbg(x) (std::cout << #x << " = " << x << endl)
- #define twopow(x) ((((x & (x - 1)) == 0) && (x != 0)) ? (true) : (false))
- #define mod(n, m) ((n >= 0) ? (n % m) : ((abs(n) % m) == 0) ? 0 : (m - (abs(n) % m)))
- using namespace std;
- int t;
- vector <string> v;
- vector <string> v2;
- std::tr1::unordered_map <string, string> mp;
- std::tr1::unordered_map <string, string> mp2;
- char str[5000010], key[100010], value[100010];
- int main(){
- //read();
- scanf("%d", &t), getchar();
- for (int line = 1; line <= t; line++){
- mp.clear(), mp2.clear(), v.clear(), v2.clear();
- gets(str);
- char* pch = strtok(str, "{,}");
- while (pch != 0){
- int j = 0, k = 0;
- for (j = 0; pch[j] != ':'; j++) key[k++] = pch[j];
- key[k] = 0, k = 0;
- for (++j; pch[j] != 0; j++) value[k++] = pch[j];
- value[k] = 0;
- mp[key] = value;
- v.push_back(key);
- pch = strtok(0, "{,}");
- }
- gets(str);
- pch = strtok(str, "{,}");
- while (pch != 0){
- int j = 0, k = 0;
- for (j = 0; pch[j] != ':'; j++) key[k++] = pch[j];
- key[k] = 0, k = 0;
- for (++j; pch[j] != 0; j++) value[k++] = pch[j];
- value[k] = 0;
- mp2[key] = value;
- v2.push_back(key);
- pch = strtok(0, "{,}");
- }
- int counter = 0;
- bool printed = false;
- int len = v.size(), len2 = v2.size();
- sort(v.begin(), v.end()), sort(v2.begin(), v2.end());
- counter = 0;
- for (int i = 0; i < len2; i++){
- string lol = mp[v2[i]];
- if (lol.length() == 0){
- printed = true;
- if (counter != 0) putchar(',');
- if (counter == 0) putchar('+');
- printf("%s", v2[i].c_str());
- counter++;
- }
- }
- if (counter != 0) putchar(10);
- counter = 0;
- for (int i = 0; i < len; i++){
- string lol = mp2[v[i]];
- if (lol.length() == 0){
- printed = true;
- if (counter != 0) putchar(',');
- if (counter == 0) putchar('-');
- printf("%s", v[i].c_str());
- counter++;
- }
- }
- if (counter != 0) putchar(10);
- counter = 0;
- for (int i = 0; i < len; i++){
- string lol = mp[v[i]];
- string lol2 = mp2[v[i]];
- if (lol.length() != 0 && lol2.length() != 0){
- if (strcmp(lol.c_str(), lol2.c_str()) != 0){
- printed = true;
- if (counter != 0) putchar(',');
- if (counter == 0) putchar('*');
- printf("%s", v[i].c_str());
- counter++;
- }
- }
- }
- if (counter != 0) putchar(10);
- if (!printed) puts("No changes");
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement