题目描述:

解题思路:

1.根据:和,获得字符串

2.使用两个map进行比较;

 #include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
map<string, string>::iterator it;
map<string,string> dict[];
string str[];
int main(int argc, char *argv[])
{
int t ;
cin >> t;
while(t--)
{
dict[].clear(), dict[].clear();
for(int i=;i<;i++)
{
string s,t1,t2;
cin >> s ;
int j=,len = s.size() ;
while(j < len && len > )
{
while(s[j]!=':') t1 += s[j++] ; ++j ;
while(s[j]!=',' && s[j]!='}') t2 += s[j++] ; ++j ;
dict[i][t1] = t2 ;
t1 = t2 = "" ;
}
}
int a=,s=,m=;
for(it=dict[].begin();it != dict[].end();it++)
if(!dict[].count(it->first)) str[a++] = it->first;
if(a)
{
sort(str,str+a);
cout << "+" << str[] ;
for(int i = ; i < a; ++i) cout << ',' << str[i];
puts("");
}
for(it=dict[].begin();it != dict[].end();it++)
if(!dict[].count(it->first)) str[s++] = it->first;
if(s)
{
sort(str,str+s);
cout << "-" << str[] ;
for(int i = ; i < s; ++i) cout << ',' << str[i];
puts("");
}
for(it=dict[].begin();it != dict[].end();it++)
if(dict[].count(it->first)&&dict[][it->first] != it->second) str[m++] = it->first;
if(m)
{
sort(str,str+m);
cout << "*" << str[] ;
for(int i = ; i < m; ++i) cout << ',' << str[i];
puts("");
}
if(!(a || s || m)) puts("No changes");
puts("");
}
return ;
}

更新字典 (Updating a Dictionary,UVa12504)的更多相关文章

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

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

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

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

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

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

  4. Problem C Updating a Dictionary

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

  5. 字典学习(Dictionary Learning, KSVD)详解

    注:字典学习也是一种数据降维的方法,这里我用到SVD的知识,对SVD不太理解的地方,可以看看这篇博客:<SVD(奇异值分解)小结 >. 1.字典学习思想 字典学习的思想应该源来实际生活中的 ...

  6. 字典学习(Dictionary Learning)

    0 - 背景 0.0 - 为什么需要字典学习? 这里引用这个博客的一段话,我觉得可以很好的解释这个问题. 回答这个问题实际上就是要回答“稀疏字典学习 ”中的字典是怎么来的.做一个比喻,句子是人类社会最 ...

  7. csuoj 1113: Updating a Dictionary

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

  8. JavaScript中创建字典对象(dictionary)实例

    这篇文章主要介绍了JavaScript中创建字典对象(dictionary)实例,本文直接给出了实现的源码,并给出了使用示例,需要的朋友可以参考下 对于JavaScript来说,其自身的Array对象 ...

  9. [Swift]LeetCode676. 实现一个魔法字典 | Implement Magic Dictionary

    Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be ...

随机推荐

  1. HDU 1290 献给杭电五十周年校庆的礼物(面分割空间 求得到的最大空间数目)

    传送门: 献给杭电五十周年校庆的礼物 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  2. qt+vs2005新建配置不自动加载Generated Files进工程(个人备份)

    工程右键Qt Project Settings 的Moc Directory路径删除 确定,再进入将删除路径加上

  3. 确认框,confirm工具封装

    用bootstrap封装了个确认框工具 效果如下 代码如下: /** * 以模态窗做确认框的函数,title为标题栏内容,body为消息体,yesFun为点击确认按钮后执行的函数,执行后会执行关闭并删 ...

  4. LeetCode 中级 - 优势洗牌(870)

    给定两个大小相等的数组 A 和 B,A 相对于 B 的优势可以用满足 A[i] > B[i] 的索引 i 的数目来描述. 返回 A 的任意排列,使其相对于 B 的优势最大化. 示例 2: 输入: ...

  5. ExcludeClipRect区域裁剪问题

    CPaintDC dc(this); CRect rt1; CPen newPen; newPen.CreatePen(PS_SOLID,1,RGB(0,0,0)); CPen *pOldPen = ...

  6. spark启动原理总结

    一般情况下,我们启动spark集群都是start-all.sh或者是先启动master(start-master.sh),然后在启动slave节点(start-slaves.sh),其实翻看start ...

  7. Leecode刷题之旅-C语言/python-217存在重复元素

    /* * @lc app=leetcode.cn id=217 lang=c * * [217] 存在重复元素 * * https://leetcode-cn.com/problems/contain ...

  8. Go搭建一个博客系统

    go语言环境就不用多说了,版本肯定越高越好,这里用go1.10 先放着

  9. Emgucv安装及使用

    Emgucv安装 最近有个客户联系我,希望我能够为他们做一个识别瓷砖花纹的软件.应用场景是这样的:现场会有一个摄像头去拍摄流水线上运输的瓷砖,如果检测这块瓷砖的花纹不符合要求,则需要给PLC或输出板卡 ...

  10. 在XAML中为ItemsControl定义分组,适合mvvm绑定

    可以先参考一下这个文章: http://www.cnblogs.com/zoexia/archive/2014/11/30/4134012.html step0: 先展示一下最简陋的界面: 上图是一个 ...