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

【题意】

在这里输入题意

【题解】

不确定某个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. Resize图片

    在网站上传图片的时候,提示图片太大了. 有5种方式来调整图片大小 http://www.wikihow.com/Resize-a-JPEG picresize.com 这个网站比较靠谱:使用Windo ...

  2. tensorflow 语法及 api 使用细节

    1. tf.nn.conv2d 的参数 padding='SAME' ⇒ 卷积之前的大小和卷积之后的大小一致,默认使用全 0 填充: padding='VALID' ⇒ 也即仅适用其有效部分,而不使用 ...

  3. OpenCV —— 摄像机模型与标定

    这种理论看的已经够多了,感觉应用价值不大(矫正畸变图像还凑合,用摄像机测距神马的...) 有始有终吧,简单把内容梳理一下 针孔  摄像机模型 —— 过于理想(不能为快速曝光收集足够的光线) 透镜可以聚 ...

  4. jupyter sparkmagic on hdp

    1.安装jupyter 2.安装sparkmagic 3.设置超时 "livy_server_heartbeat_timeout_seconds": 0, 4.设置集群模式 &qu ...

  5. 搭建 Docker 环境

  6. vue2细节变化的用法

    1.v-el和v-ref合并为一个属性:ref 原来:v-el:my-element 现在: ref="myElement", v-ref:my-component 变成了这样:  ...

  7. POJ 4047 Garden

    Garden Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 404 ...

  8. 用 runcloud.io 免费部署、优化管理你的多个VPS( 目前支持 Ubuntu 16.04 )

    使用RunCloud.io轻松实现Web部署 使用VPS.云服务器,通常会安装基本的操作系统,之后必须自己安装Apache,MySQL,PHP,尤其是服务器的性能优化,这对大多数人来说可能是非常具有挑 ...

  9. 汉化 Hirens.BootCD 中的 XP 系统

    汉化 Hirens.BootCD 中的 XP 系统 1. 在中文版 XPSP3 镜像中提取所需的文件 原系统为没有作 server pack 的 Windows XP Professional ,在W ...

  10. golang sync.RWMutex

    sync.RWMutex package main import ( "fmt" "runtime" "sync" ) func click ...