摘要:
主要是记得传比较算子进去,优先队列要的那个算子参数大概是用来定义优先级的,默认是less,大概是优先级低的先出队。想要从小到大排序要传greater进去。 1 priority_queue,greater > Q; 2 Q.push(make_pair(0,1));dis[1]=0;... 阅读全文
摘要:
先上代码#include using namespace std;int main(){ // vector::iterator it=const_cast::iterator >(v.begin()); // vector::iterator it=(v.begin()); const int a=0; int &b=const_cast(a); //int &b=(int &)a;这个也可以 b=10; cout(&c); // int *d=(int *)&c; *d=10; cout<<c<<','& 阅读全文
摘要:
大白书例题 uva11922留个splay模板虚拟节点可以是放个最小的也可以放最大的,两种方法对同一个点会导致名次相差一。弄一个节点当null确实比较方便一开始序列转化成树居然可以直接搞出一条链也没问题,这个略屌。#include #include using namespace std;struc... 阅读全文
摘要:
定义一个指针,使得其指向一个一维数组的空间,并且能被当做三维数组名用。 当时暑假问的tbc Code#includeusing namespace std;int a[1000];int main(){ int (*p)[10][10]=(int(*)[10][10])&a[0]; cout>i>>j>>k) cout<<p[i][j][k]<<endl; return... 阅读全文
摘要:
1.感觉之前邵叔叔教的做fib的那个支持删除(其实删除只是打标记,而且不支持插入。。。)和查询的排序二叉树就是个静态的名次树嘛。我居然学到了这么奇怪的数据结构。。。2.写的时候坑了几次 (1)不要乱用引用,getKth里那个参数o没过脑子用了引用,结果把树搞烂了,一堆ch[x]赋值成NULL了。 (2)写查找的时候lchsize#include #include #include using namespace std;struct Node { Node *ch[2]; int r,v,s; Node(int v):v(v) ... 阅读全文
摘要:
下面搜到的set的一些说明在这里搜到的 http://blog.csdn.net/xuruoxin/article/details/12654093 Code set的基本操作:begin() 返回指向第一个元素的迭代器clear() 清除所有元素count() 返回某个值元素的个数empty() 如果集合为空,返回trueen... 阅读全文
摘要:
没过,不想写了。。。唉。。。网上找了了代码对拍都拍不出错数据。。。。这泥煤。。。。。。。。。 有大神能帮忙看出来哪里错了就太感谢了。。。。 Code#include #include #include using namespace std;const int MAXB=21+10,MAXG=8+10;int c[MAXB][MAXG],res[(1>G>>B>>S){ if((... 阅读全文
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4973ZOJ Problem Set - 3690Code#include #include using namespace std;struct Matrix{ #define ... 阅读全文
摘要:
最近翻了一下暑假的代码,发现了点有用的东西。 斜堆 记得是个猴子打架的题目 Code#include #include #include using namespace std;const int N=100000;int f[N+10],head[N+10],lch[N+10],rch[N+10],w[N+10];int merge(int A,int B) { if(A=... 阅读全文
摘要:
多模式串匹配,在给出的字符串中查找出现了几个模板串。允许模板串重复,某一个模板串是另一个的前缀或后缀。http://acm.hdu.edu.cn/showproblem.php?pid=2222#include #include #include #define maxnode 550000... 阅读全文