2014年1月7日

POJ 3169 Layout 差分约束系统

摘要: d_x d_x d_y = mind --> d_x que; int dis[maxn]; void addedge(int u,int v,int c){ edges[edge].w=c,edges[edge].to=v,edges[edge].next=head[u],head[u]=edge++; } void init(int n){ memset(head,-1,sizeof(head)); edge=0; this->n=n; } bool spfa(int s){ in... 阅读全文

posted @ 2014-01-07 22:56 电子幼体 阅读(115) 评论(0) 推荐(0) 编辑

ZOJ 2334 Monkey King 可并堆左偏树

摘要: ----------int n,m;class LeftistTree{private: int tot,v[maxn],l[maxn],r[maxn],d[maxn];public: int merge(int x,int y){ if (!x) return y; if (!y) return x; if (v[x]<v[y]) swap(x,y); r[x]=merge(r[x],y); if (d[l[x]]<d[r[x]]) swap(l[x],r[x]); d[x]=d[r[x]]+1;... 阅读全文

posted @ 2014-01-07 22:10 电子幼体 阅读(144) 评论(0) 推荐(0) 编辑

ZOJ 2112 Dynamic Rankings 线段树套平衡树

摘要: ------------const int N=60010;const int M=10010;class SegmentTree_Treap{private: struct Treap{ int key,fix,cnt,size,ch[2]; }T[N*15]; int tree[Nt) return select(T[x].ch[0],t); return T[x].cnt+T[T[x].ch[0]].size+select(T[x].ch[1],t); }public: void treeins(int l,int r,int i... 阅读全文

posted @ 2014-01-07 00:09 电子幼体 阅读(119) 评论(0) 推荐(0) 编辑

导航