传送门

•前置知识-multimap的用法

  $multimap$ 与 $map$ 的区别在于一个 $key$ 可以对应几个值;

  对于 $map$ 而言,一个 $key$ 只能对应一个值,并且按照 $key$ 升序排列;

  而 $multimap$ 的一个 $key$ 可以对应多个值,并且按照 $key$ 升序排列;

  但是,相同的 $key$ 对应的多个值按照插入的顺序排列,不会自动排序;

  • 定义:$multimap<char ,int >f$
  • 插值
    • $f.insert(make\_pair('a',10))$
    • $f.insert(make\_pair('a',20))$
    • $f.insert(make\_pair('a',15))$
    • $f.insert(make\_pair('b',10))$
  • 遍历相同 $key$ 的所有值
    • $for(auto\ it=f.equal\_range('a').first;it\neq f.equal\_range('a').second;++it)\\ cout<<(*it).second<<endl;$

CodeForces 1243"Character Swap (Hard Version)"(multimap)的更多相关文章

  1. Codeforces Round #599 (Div. 2) B2. Character Swap (Hard Version) 构造

    B2. Character Swap (Hard Version) This problem is different from the easy version. In this version U ...

  2. Codeforces Round #599 (Div. 2) B1. Character Swap (Easy Version) 水题

    B1. Character Swap (Easy Version) This problem is different from the hard version. In this version U ...

  3. Saving James Bond - Easy Version (MOOC)

    06-图2 Saving James Bond - Easy Version (25 分) This time let us consider the situation in the movie & ...

  4. codeforces 765 D. Artsem and Saunder(数学题)

    题目链接:http://codeforces.com/contest/765/problem/D 题意:题目中给出你两个公式,g(h(x))==x,h(g(x))==f(x).现给你f(x) 让你求符 ...

  5. CodeForces 165C Another Problem on Strings(组合)

    A string is binary, if it consists only of characters "0" and "1". String v is a ...

  6. 【CodeForces 697C】Lorenzo Von Matterhorn(LCA)

    Least Common Ancestors 节点范围是1~1e18,至多1000次询问. 只要不断让深的节点退一层(>>1)就能到达LCA. 用点来存边权,用map储存节点和父亲连边的权 ...

  7. Codeforces Round #306 (Div. 2) ABCDE(构造)

    A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全, ...

  8. Codeforces 606-C:Sorting Railway Cars(LIS)

    C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. codeforces 319B Psychos in a Line(模拟)

    There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At eac ...

随机推荐

  1. 写GULP遇到的ES6问题详解

    Gulp.js 是一个自动化构建工具,开发者可以使用它在项目开发过程中自动执行常见任务.最近复习一下gulp一些基本的写法,在写了一些简单的uglify,rename,concat,clean的处理之 ...

  2. String int 变量互相转化

    int -> String int i=12345;String s="";第一种方法:s=i+"";第二种方法:s=String.valueOf(i); ...

  3. 值得研究的J2EE开源项目推荐

    导读:笔者在学习J2EE的过程中发现了一些很有用,而且很值得学习的开源项目,在此推荐给大家. 关键词:J2EE 开源项目 J2SE JBoss SOA EJB   这篇文章写在我研究J2SE.J2EE ...

  4. nginx+tomcat集群+redis(memcache)session共享!

    常用保持session的方式: 1.一些代理(比如nginxIP_hash) 1.使用数据库来存储Session 2.使用Cookie来存储Session                       ...

  5. python 在init方法中导入数据

  6. More Effective C++: 06杂项讨论

    32:在未来时态下发展程序 世事永远在变,好的软件对于变化有良好的适应能力:可以容纳新的性质,可以移植到新的平台,可以适应新的需求,可以掌握新的输入.所谓在未来时态下设计程序,就是接受“事情总会改变” ...

  7. JavaScript--查看代码运行效率console.time()与console.timeEnd()用法

    程序运行时间计算: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  8. Codeforces 414B

    题目链接 附上代码: #include<cstdio> #include<cstring> #include<bits/stdc++.h> #define mod ...

  9. Android实战:手把手实现“捧腹网”APP(二)-----捧腹APP原型设计、实现框架选取

    Android实战:手把手实现"捧腹网"APP(一)-–捧腹网网页分析.数据获取 Android实战:手把手实现"捧腹网"APP(二)-–捧腹APP原型设计.实 ...

  10. java返回结果集封装

    1.返回消息统一定义文件CodeMsg.java public class CodeMsg { private int retCode; private String message; // 按照模块 ...