stlinacm(编辑修改稿)内容摘要:

ap(), pop_heap() … in algorithm 用法举例 : include queue include vector using namespace std。 priority_queue int maxheap。 //int最大堆 struct ltstr { bool operator()(int a,int b) {return a b。 } }。 priority_queue int,vectorint,ltstr minheap。 //int最小堆 hash_map 内部实现 : Hash表 , of course  hash_mapKey, Data, HashF, EqualKey, Alloc 重载 HashF和 EqualKey 支持操作 : insert()。 O(1) earse()。 O(1) [ ]。 O(1) 示例: Again TOJ 1378 Babelfish See also: hash_set hash_multimap hash_multiset include cstdio include //?? include string using namespace std。 struct calc_hash { size_t operator()(string str) const { unsigned long h = 0。 int i。 for (i = 0。 i ()。 i++) { h = 5。 h |= str[i] 39。 a39。 } return (size_t)h。 //h%M?? } }。 struct eqstr { bool operator()(string s1, string s2) {return s1 == s2。 } }。 //本题此处可省略 int main() { hash_mapstring,string,calc_hash hp。 char buf[100],s1[20],s2[20]。 while (gets(buf)) { if (strlen(buf) == 0) break。 sscanf(buf,%s%s,s1,s2)。 hp[(string)s2] = (string)s1。 } while (gets(buf)) { if (((string)buf) != ()) printf(%s\n,hp[(string)buf].c_str())。 else printf(eh\n)。 } return 0。 } algorithm () void sort(RandomAccessIterator first, RandomAccessIterator last)。 void sort(RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering p)。 区间 [first,last) Quicksort,复杂度 O(nlogn) (n=lastfirst,平。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。