![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
nywsp
这个作者很懒,什么都没留下…
展开
-
nyoj 116 士兵杀敌(二) 树状数组
树状数组图解#include#includeint m,n,c[1000005];int xb(int x)//查找下标{ return x&(x^(x-1));}int sum(int x)//求和{ int sum=0; while(x>0) { sum+=c[x]; x-=xb(x); } return sum;}void gb(int x,in原创 2012-11-03 15:59:22 · 944 阅读 · 1 评论 -
poj 1840 (hash)
题意:给你一个多元多项式,并给定你多项式的系数,让你求在[-50,50]区间内可能的值的组合思路:a1x1^3+ a2x2^3+ a3x3^3 = -(a4x4^3 + a5x5^3)先求出左边能到达的值,对值进行hash。用结构体hash速度比较慢2000+ms,用字符数组能标记到25000000,而且速度只有600+ms。虽然能在poj上通过但是它只能存一个字节的数如果是要记录原创 2012-12-06 21:39:59 · 385 阅读 · 0 评论 -
邻接表模版c+
#include#includeint h[602],b;struct st{ int next,v,s;}st[100000];void init(){ b=1; memset(h,0,sizeof(h));}void add(int ne,int v,int s){ st[b].v=v; st[b].s=s; st[b].next=h[ne]; h[ne]=b转载 2012-10-21 14:28:51 · 571 阅读 · 0 评论 -
最小生成树 克丽丝卡尔算法 hdu1879 继续畅通工程
克丽丝卡尔算法的主要思想是将两点之间的距离排序,。,,然后从小到大依此用并查集判断这条边是不是构成环,,若不是环就能就能用上。。。。题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1879 #include#include#include#define max 100000int n,zx[101];struct node{原创 2012-07-25 17:02:55 · 4049 阅读 · 0 评论 -
nyoj 237 最小点覆盖集 vector的使用
最小点覆盖集=最大匹配。。。#include#include#include#include using namespace std;vector st[503];int m,n,u,use[503],lin[503];int find(int v){ int i,j; for(i=0;i<st[v].size();i++) { int原创 2012-12-10 19:25:03 · 571 阅读 · 0 评论 -
优先队列模版
#include#include#include #includeusing namespace std;struct cp1{ bool operator()(int x,int y) { return x<y; }};struct cp2{ int x,y; friend bool operator<(cp2 a,cp2 b)原创 2013-03-21 09:15:59 · 660 阅读 · 0 评论 -
nyoj 542 map vector使用
#include#include#include#include#include#include#include#includeusing namespace std;vectorf[401];//存贮前面的 化学式vectore[501];//后面的vectorall;//新生的maphave;//已知的char s[110];void f原创 2014-03-20 11:35:54 · 568 阅读 · 0 评论 -
士兵杀敌四 树状数组之插点问线
#include#define max 1000003int c[max],m;int lowbit(int k){return k&(-k);}void add(int k,int he)//前k项都增加he{while(k>0){c[k]+=he;k-=lowbit(k);}}void Q(int k)//查询{int query=0;while(k<=原创 2014-03-20 11:39:09 · 572 阅读 · 0 评论 -
归并快排模版
#include#includeusing namespace std;int st[1000010];long long sum;void merge(int e1,int t1,int e2,int t2){ int* ne=new int[t2-e1+5]; int fl=0,i; int m=e1,n=e2; while(m<=原创 2012-11-23 13:32:13 · 467 阅读 · 0 评论