【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

不确定某个map里面是否有某个关键字的时候。
要用find来确定。
如果直接用访问下标的形式去做的话。
会强行给他加一个那个关键字(原来没有).
(当然那个关键字的映射为空就是了);

【代码】

#include <bits/stdc++.h>
using namespace std; string s;
map<string, string> mmap1, mmap2;
vector <string> v[3]; void getmap(map<string, string> &mmap, string s)
{
int len = s.size();
for (int i = 0; i < len; i++)
if (s[i] == '{' || s[i] == ':' || s[i] == ',' || s[i] == '}')
s[i] = ' ';
string a, b;
stringstream ss(s);
while (ss >> a >> b)
{
mmap[a] = b;
}
} int main()
{
//freopen("F:\\rush.txt", "r", stdin);
int unused;
cin >> unused;
while (unused--)
{
for (int i = 0; i < 3; i++)v[i].clear();
mmap1.clear(); mmap2.clear();
cin >> s;
getmap(mmap1, s);
cin >> s;
getmap(mmap2, s);
for (auto temp : mmap2)
if (mmap1.find(temp.first)==mmap1.end()) v[0].push_back(temp.first); for (auto temp : mmap1)
if (mmap2.find(temp.first)==mmap2.end()) v[1].push_back(temp.first); for (auto temp : mmap1)
if (mmap2.find(temp.first)!=mmap2.end() && mmap2[temp.first] != temp.second)
{
string s1 = temp.second, s2 = mmap2[temp.first];
v[2].push_back(temp.first);
}
bool ok = v[0].empty() && v[1].empty() && v[2].empty();
if (ok) cout << "No changes" << endl;
else
{
for (int i = 0; i < 3; i++)
if (!v[i].empty())
{
if (i == 0) cout << '+';
if (i == 1) cout << '-';
if (i == 2) cout << '*';
cout << v[i][0];
for (int j = 1; j < (int)v[i].size(); j++)
cout << "," << v[i][j];
cout << endl;
}
} cout << endl;
}
return 0;
}

【习题 5-11 UVA 12504 】Updating a Dictionary的更多相关文章

  1. [ACM_模拟] UVA 12504 Updating a Dictionary [字符串处理 字典增加、减少、改变问题]

      Updating a Dictionary  In this problem, a dictionary is collection of key-value pairs, where keys ...

  2. Uva - 12504 - Updating a Dictionary

    全是字符串相关处理,截取长度等相关操作的练习 AC代码: #include <iostream> #include <cstdio> #include <cstdlib& ...

  3. 【UVA】12504 Updating a Dictionary(STL)

    题目 题目     分析 第一次用stringstream,真TMD的好用     代码 #include <bits/stdc++.h> using namespace std; int ...

  4. Uva 511 Updating a Dictionary

    大致题意:用{ key:value, key:value, key:value }的形式表示一个字典key表示建,在一个字典内没有重复,value则可能重复 题目输入两个字典,如{a:3,b:4,c: ...

  5. csuoj 1113: Updating a Dictionary

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 1113: Updating a Dictionary Time Limit: 1 Sec  ...

  6. 湖南生第八届大学生程序设计大赛原题 C-Updating a Dictionary(UVA12504 - Updating a Dictionary)

    UVA12504 - Updating a Dictionary 给出两个字符串,以相同的格式表示原字典和更新后的字典.要求找出新字典和旧字典的不同,以规定的格式输出. 算法操作: (1)处理旧字典, ...

  7. [刷题]算法竞赛入门经典(第2版) 5-11/UVa12504 - Updating a Dictionary

    题意:对比新老字典的区别:内容多了.少了还是修改了. 代码:(Accepted,0.000s) //UVa12504 - Updating a Dictionary //#define _XieNao ...

  8. Problem C Updating a Dictionary

    Problem C     Updating a Dictionary In this problem, a dictionary is collection of key-value pairs, ...

  9. Updating a Dictionary UVA - 12504

    In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, a ...

随机推荐

  1. spring cloud config配置中心源码分析之注解@EnableConfigServer

    spring cloud config的主函数是ConfigServerApplication,其定义如下: @Configuration @EnableAutoConfiguration @Enab ...

  2. 跨域使用onmessage实现方式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. CString与 char *之间的转换

    http://www.cnblogs.com/watsonlong/archive/2011/04/15/2017086.html

  4. HDU 4696 Answers 水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4696 由题意可知 1<=Ci<=2 而且图上一定有环 那么我们可以得出: 只要存在奇环(即Ci=1) ...

  5. 【DRF解析器和渲染器】

    目录 解析器 Django中的解析器 DRF中的解析器 DRF中的渲染器 @ *** 解析器 解析器的作用就是服务端接收客户端传过来的数据,把数据解析成自己想要的数据类型的过程. 本质就是对请求体中的 ...

  6. [置顶] Docker学习总结(3)——Docker实战之入门以及Dockerfile(三)

    应用镜像 csphere/wordpress:4.2 # cd docker-training/wordpress/ # ls -a . license.txt wp-config-sample.ph ...

  7. virmon防火墙64位正式版(暂定)公布

    ChangeLog: 2015-06-2564位版本号签名问题临时得到解决.还要致谢一下某位黑客. 支持版本号x64 Windows Vista.7.8.8.1以上等.个人仅仅在Windows7上做了 ...

  8. ubuntu下sudo命令不再输入密码

    ubuntu下普通用户是没有root权限,很多命令在使用时都需要使用命令sudo 'cmd',但系统需要user验证自己,即需要输入普通用户的密码.但普通用户是否有执行该cmd的权限,需要到系统文件/ ...

  9. UVA 11346 Probability (几何概型, 积分)

    题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=2321">https://uva ...

  10. shape- 设置虚线

    <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http: ...