
[ACM]_STL
同学少年
没有什么不可能!
展开
-
[ACM] 常用STL
1. stack stackst;//栈st,用于存放int型数据 st.push(3);//将3入栈 st.push(2);//将2入栈 st.pop();//栈顶2出栈 int Top = st.top();//获取栈顶元素,即3 int Size = st.size();//求栈中的元素个数 bool isEmpty = st.empty(); //栈中元素是否为空,1表示空,0表示非空原创 2016-03-01 19:10:18 · 3554 阅读 · 0 评论 -
[ACM] POJ 3096 Surprising Strings (map的使用)
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5783 Accepted: 3792 Description The D-pairs of a string of letters are the ordered pai原创 2014-07-23 20:02:19 · 1562 阅读 · 0 评论 -
[ACM] POJ 2418 Hardwood Species (Trie树或者map)
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 17986 Accepted: 7138 Description Hardwoods are the botanical group of trees that have b原创 2014-07-19 17:35:01 · 2917 阅读 · 0 评论 -
[ACM] POJ 1442 Black Box (堆,优先队列)
解题思路: 给出一串数字序列,依次添加,问原创 2014-07-18 13:37:47 · 3750 阅读 · 0 评论 -
[ACM] POJ 3253 Fence Repair (Huffman树思想,优先队列)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 25274 Accepted: 8131 Description Farmer John wants to repair a small length of the fence aro原创 2014-07-18 08:19:23 · 1994 阅读 · 0 评论 -
[ACM] POJ 2442 Sequence (堆的性质)
解题思路: 有m行,每行n个数,从每行中取出一个数相加一起求出sum,这样的sum有n的m次方个。要求的前n个最小的sum值。 第一次使用STL里面的堆,一开始对pop_heap()有点不太理解,后来明白了,比如对数组heap[n],最大下标为n-1建堆,默认的是建立大顶堆,heap[0]是数组中最大的数,写一条pop_heap()语句,就是把heap[0]和 heap[n原创 2014-07-17 20:18:59 · 2216 阅读 · 1 评论