题目描述:

解题思路:

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. C# 5.0中使用CallerMemberName、CallerFilePath和CallerLineNumber获取代码的调用方信息(转载)

    很多时候,我们需要在运行过程中记录一些调测的日志信息,如下所示: public void DoProcessing() { TraceMessage("DoProcessing()被XXX调 ...

  2. 100个常用的linux命令(转)

    来源:JavaRanger – javaranger.com   http://www.javaranger.com/archives/907 1,echo “aa” > test.txt 和 ...

  3. iOS11.2-11.3.1进行越狱及问题

    设备环境:Electra.iOS11.13.1 PS:Electra最新版本进行越狱只支持11.14以下的版本.同时这是不完美越狱,每次重启手机都需要重新越狱,最后,由于Electra版本推出仓促,一 ...

  4. OC录制小视频

    OC录制小视频 用 AVCaptureSession + AVCaptureMovieFileOutput 来录制视频,并通过AVAssetExportSeeion 手段来压缩视频并转换为 MP4 格 ...

  5. js检测是否可以访问公网服务器

    wifi认证开发过程所用到的,源码如下: 注:检测AC是否放行成功,是否可以访问公网阿里云服务器 功能调用: checkNet().then(function(res) { if(res) { //连 ...

  6. 小K的农场(差分约束,spfa)

    题目描述 小K在MC里面建立很多很多的农场,总共n个,以至于他自己都忘记了每个农场中种植作物的具体数量了,他只记得一些含糊的信息(共m个),以下列三种形式描述: 农场a比农场b至少多种植了c个单位的作 ...

  7. 转:Java并发集合

    引自:http://ifeve.com/concurrent-collections-1/ 并发集合(一)引言 声明:本文是< Java 7 Concurrency Cookbook>的第 ...

  8. 使用js实现单向绑定

    详细解释单向绑定 参考资料 MDN addEventListener()定义与用法 <!DOCTYPE html> <html lang="en"> < ...

  9. python爬虫学习笔记(1)

    一.请求一个网页内容打印 爬取某个网页: from urllib import request # 需要爬取的网页 url = "https://mbd.baidu.com/newspage ...

  10. c语言程序设计:用strcpy比较数组(银行卡密码程序设计),strcpy(复制数组内容)和getchar()(敲键盘字符,统计不想要的字符的个数)

    统计从键盘输入一行字符的个数: 1 //用了getchar() 语句 2 //这里的\n表示回车 #include <stdio.h> #include <stdlib.h> ...