//只能拿某些特定个数的石子 #include <cstring> #include <iostream> #include <algorithm> #include <unordered_set> using namespace std; const int N = 110, M = 10010; ...
考场用的set,代码复杂度很低,时间复杂度$O(sum log)$,一发过了大样例,以为1e6的数据很稳了就没再管(然后就挂掉了……) 考后把set化成unordered_set就A了。其实$sum log$的时间复杂度是没有什么问题,只不过有个细节没有考虑好,考场上以为set赋值和clear的复杂 ...
分类:
其他好文 时间:
2019-10-17 22:03:56
阅读次数:
107
滑动窗口思想: 如对于abcabcab,无重复字符的最长字串为abc,长度为3。使用滑动窗口思想,当窗口为abc时,再进入a,队列变为abca,不满足要求,需要移动窗口。移动的方法为抛弃最左边的字符,即a,持续该操作,直到序列末尾。 注:unordered_set用来判断只去重不重复的需求(set是 ...
分类:
其他好文 时间:
2019-10-05 00:59:01
阅读次数:
87
下面是map,set,unordered_map,unordered_set的性能分析。 map,内部红黑树,插入复杂度O(logn),查找复杂度O(logn),用键值对应value; set,内部红黑树,插入复杂度O(logn),查找复杂度O(logn),只有value不存在键值; unorder ...
分类:
其他好文 时间:
2019-10-02 11:10:44
阅读次数:
101
C++11新增了一类散列容器包括unordered_set, unordered_map, unordered_multiset, unordered_multimap, 即之前熟悉的hash_set, hash_map等。 这类容器底层以哈希表实现之,通过unordered_map介绍下这类容器的 ...
分类:
编程语言 时间:
2019-09-22 19:24:44
阅读次数:
149
Boost.Unordered provides the classes boost::unordered_set, boost::unordered_multiset, boost::unordered_map, and boost::unordered_multimap. These class ...
分类:
其他好文 时间:
2019-06-13 20:21:25
阅读次数:
99
unordered_set:容器内的元素无序排列,基于值进行获取单个元素速度非常快。内部根据它们的 hash value 被组织成 buckets(slot)。 Iterators begin: 有两个类型:container iterator(1); bucket iterator。 end: 同 ...
分类:
编程语言 时间:
2019-01-30 00:19:33
阅读次数:
177
介绍了STL中各类容器及其使用方法,序列容器(vector, deque, list, forward_list, array),关联容器(set, multiset, map, multimap),无序容器(unordered_set, unordered_multiset, unordered... ...
分类:
其他好文 时间:
2018-12-30 20:36:12
阅读次数:
297
class Solution { public: string mostCommonWord(string paragraph, vector& banned) { unordered_set s(banned.begin(), banned.end()); unordered_map m; int... ...
分类:
其他好文 时间:
2018-11-20 01:30:16
阅读次数:
233
water #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define mp make_pair #define x first #define y s ...
分类:
其他好文 时间:
2018-09-16 12:31:40
阅读次数:
152