map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value。假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区分),我们用map来进行存储就是个不错的选择。 我们这样定义,map<string, int>,其中学生姓名用string类型,作为Ke ...
分类:
编程语言 时间:
2016-09-06 23:03:35
阅读次数:
329
可持久化数据结构 题目链接:http://acm.xidian.edu.cn/problem.php?id=1181 用vector实现可持久化 这题要求的是一个支持区间查询的可持久化数据结构。这里使用vector巧妙地实现:pair<time,value>用pair存储时间戳以及当前时间的值,qu ...
分类:
其他好文 时间:
2016-09-06 21:19:12
阅读次数:
188
题目链接:http://codeforces.com/gym/100507/attachments 刚看这题的时候感觉是区间$DP$ 然而复杂度一直停留在$O(n^3)$优化不下来 后来又瞎试了一些贪心 都在较大的数据上挂掉了 反复琢磨着大写字母和相应小写字母匹配 便想到了以前做过的括号匹配 只不过 ...
分类:
其他好文 时间:
2016-09-05 19:26:26
阅读次数:
154
Portal: http://codeforces.com/problemset/problem/190/C 一道卡输入输出的蛋疼题 题意:给你一个由pair和int所组成的沙茶字符串(最大含有1e5个单词),输出合法的pair序列 这道题可以拿栈做,也就是vector或stack 呵呵 (vect ...
分类:
其他好文 时间:
2016-09-05 14:00:39
阅读次数:
374
10892 LCM CardinalityA pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs. For example 12 is the LCM o ...
分类:
其他好文 时间:
2016-09-04 01:40:54
阅读次数:
182
题目名称 改造二叉树 数字对 交换 英文名称 binary pair swap 输入文件名 binary.in pair.in swap.in 输出文件名 binary.out pair.out swap.out 时间限制 1s 2s 1s 空间限制 256M 256M 256M 测试点数目 20 ...
分类:
其他好文 时间:
2016-09-02 12:57:30
阅读次数:
280
当用decltype来获得一个函数指针类型时,必须加上一个*来指出我们要使用一个给定函数类型的指针。decltype<CompareIsbn>*。 map<string, int>::value_type v3; //v3 是一个pair<const string, int> 由于下标操作可能插入一 ...
分类:
其他好文 时间:
2016-09-01 20:00:56
阅读次数:
220
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges mak ...
分类:
其他好文 时间:
2016-08-29 12:45:43
阅读次数:
173
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from th ...
分类:
其他好文 时间:
2016-08-29 08:04:09
阅读次数:
243
原题链接 Problem Description There are n people and m pairs of friends. For every pair of friends, they can choose to become online friends (communicating ...
分类:
其他好文 时间:
2016-08-27 22:02:22
阅读次数:
180