题目描述:

解题思路:

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. [node.js学习]为node.js写的一个操作mysql的类

    不支持一个对象在不同异步中使用,模仿的php框架 speedphp中的model模块 GaryMysql.js var mysql = require('mysql'); var pool = nul ...

  2. MATLAB PCHIP函数一阶求导分析

    MATLAB PCHIP函数一阶求导分析 摘要:本文首先根据三次立方插值的一般表达式,得出分段三次立方插值时,每个小区间上的各次项系数.分析发现,三次项.二次项.一次项系数都与小区间端点处的一阶导数值 ...

  3. 【HDOJ 1337】I Hate It(线段树维护区间最大值)

    Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写 ...

  4. linux系统基础之-----磁盘结构(基于centos7.4 1708)

  5. collections.ChainMap类合并字典或映射

    ## 使用update()方法或者ChainMap类合并字典或映射 # 使用update()方法合并 a = {'x': 1, 'z': 3} b = {'y': 2, 'z': 4} merged ...

  6. nginx php-fpm 高并发优化

    PHP-php-fpm配置优化 前言: 1.少安装PHP模块, 费内存 2.调高linux内核打开文件数量,可以使用这些命令(必须是root帐号)(我是修改/etc/rc.local,加入ulimit ...

  7. laravel form 表单提交

    form表单需要加token,不然会出现419错误,csrf_token不用自己生成,放进去就行,laravel自己会生成 路由: 控制器生成一个:

  8. django创建第一个django项目-2

    安装django 虚拟环境下执行命令: pip install django==1.11.11 查看是否安装成功 pip list 列表中有django说明安装成功 创建工程 命令行移动到想要创建项目 ...

  9. 使用gogs和glide来轻松拉取golang第三方库

    golang的第三方代码拉取一直是让人头疼的问题,在github托管的代码还好,托管在其他网站上的代码总会由于大家都懂的原因,无法访问.纵使是github,在拉取文件数量较多的库时,也是比较慢的. 有 ...

  10. MySQL高级第一章——架构介绍

    一.简介 是一个经典的RDBMS,目前归属于Oracle 高级MySQL包含的内容: MySQL内核 SQL优化工程师 MySQL服务器的优化 各种参数常量设定 查询语句优化 主从复制 软硬件升级 容 ...