UVa 12504 Updating a Dictionary(更新字典)
题意 比较两个字典 按字典序输出所有添加 删除 修改的项 如果没有任何更新 输出 No changes
STL map的应用 对比两个字典 注意开始字符串的处理和字典可以为空
1 | #include<bits/stdc++.h> |
In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, and values are non-negative integers. Given an old dictionary and a new dictionary, find out what were changed.
Each dictionary is formatting as follows:
{key:value,key:value,…,key:value}
Each key is a string of lower-case letters, and each value is a non-negative integer without leading zeros or prefix `+’. (i.e. -4, 03 and +77 are illegal). Each key will appear at most once, but keys can appear in any order.
The first line contains the number of test cases T ( T1000 ). Each test case contains two lines. The first line contains the old dictionary, and the second line contains the new dictionary. Each line will contain at most 100 characters and will not contain any whitespace characters. Both dictionaries could be empty.
WARNING: there are no restrictions on the lengths of each key and value in the dictionary. That means keys could be really long and values could be really large.
For each test case, print the changes, formatted as follows:
If the two dictionaries are identical, print `No changes’ (without quotes) instead.
Print a blank line after each test case.
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}
+d,ee -b,f /*c No changes -first