随笔分类 - STL
摘要:priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式。先写一个用 STL 里面堆算法实现的与真正的STL里面的 priority_queue用法相似的priority_queue, 以加深对 priority_queue 的理解#include<iostream>#include<algorithm>#include<vector>usingnamespacestd;classpriority_queue{private:vector<int>d
阅读全文
摘要:比赛的时候竟然没有想到这题可以用树状数组过,由于数字的区间比较小,所以直接开设一个树状数组,定义sum(i) 表示小于i的数的总数。那么判定一个数是否有的条件就是计算sum(i+1) == sum(i) 便可以了,查找第K大的数,也就可以直接二分了。代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#define MAXN 100000using namespace std;int c[MAXN+5];int lowbit(int x){ r
阅读全文
摘要:I Love You TooTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 865Accepted Submission(s): 531Problem DescriptionThis is atrue story. A man showed his love to a girl,but the girl didn't replied clearly ,just gave him a Morse Code:****-/*----/----
阅读全文
摘要:题义:给定一个数字串,求出这些串的第K小组合串。 代码如下:#include <cstdio>#include <algorithm>using namespace std;int num[1005];int main( ){ int N, M; while( scanf( "%d %d", &N, &M )!= EOF ) { for( int i= 1; i<= N; ++i ) { num[i]= i; } while( --M ) { next_permutation( num+ 1, num+ N+ 1 ); } fo
阅读全文
摘要:由于对一道题目的错误理解,导致突然萌发了对与map的用法的开发,就是在形如 map< Node, int >,那么只要在重载Node的 '<'操作符时只针对个别元素,那么这些特别元素相同的结构体会被map视为相同的。 代码如下:#include <map>#include <cstdio>#include <cstring>#include <iostream>using namespace std;struct Node{ int a, b; string str; Node( int n, int m, st
阅读全文
摘要:Let the Balloon RiseTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30799Accepted Submission(s): 10110Problem DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time
阅读全文
摘要:1105: Prime PathTime Limit: 1 SecMemory Limit: 128 MBSubmit: 2Solved: 2[Submit][Status][Web Board]DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a ma..
阅读全文
摘要:Double QueueTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 4628Accepted: 2130DescriptionThe new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern information technologies.
阅读全文
摘要:HDU TodayTime Limit: 15000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3581Accepted Submission(s): 855Problem Description经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。这样住了一段时间,徐总对当地的交通还是不太
阅读全文