题目描述:

解题思路:

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 2018母牛的故事(类似斐波那契,找规律)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2018 母牛的故事 Time Limit: 2000/1000 MS (Java/Others)     ...

  2. Vim插件及.vimrc文件的配置

    关于Vim的配置基本是在.vimrc文件中完成的,该文件一般放在用户目录下. 今天安装了插件管理器Pathogen和python自动补全的插件pydiction,其中Pathogen需要事先创建两个文 ...

  3. Hibernate基础入门

    Hibernate是一个开放源代码的对象关系映射框架,它将POJO与数据库表之间建立映射关系.是全自动的ORM框架,可以自动生成SQL语句并自动执行.它对JDBC进行了非常轻量级的封装,使程序员可以随 ...

  4. vue-cli使用swiper4在ie以及safari报错

    vue-cli项目中,通过npm run swiper --save-dev安装的是swiper4版本的插件,这样安装以后在谷歌火狐等浏览器都可以正常运行,但是在safari浏览器(可能是版本太低)还 ...

  5. Mysql 之 MERGE 存储引擎

    MERGE 存储引擎把一组 MyISAM 数据表当做一个逻辑单元来对待,让我们可以同时对他们进行查询.构成一个 MERGE 数据表结构的各成员 MyISAM 数据表必须具有完全一样的表结构.每一个成员 ...

  6. shell基础知识---与监听服务器长连接端口状态

    从未写过脚本我的最近接了俩脚本的需求,就在这分享一下我的我学到基础知识主要就四部分内容 一.变量 变量的定义 string='字符串' string="字符串" num=808st ...

  7. Virtualization state: Optimized (version 7.4 installed)

    [Virtualization state: Optimized (version 7.4 installed)] [root@localhost ~]# cd /mnt/ [root@localho ...

  8. axios api封装

    import axios from 'axios'; import qs from 'qs'; const host = 'url' axios.defaults.baseURL = host; // ...

  9. MVC action过滤器验证登录

    方法一 :  1.创建一个全局action过滤器  (在appstart  的filterconfig中注册   filters.Add(new LoginAttribute());)  2.不需要登 ...

  10. itertools.groupby()分组字典列表

    ## itertools.groupby()分组字典列表数据 from operator import itemgetter from itertools import groupby student ...