摘要: int par[maxn]//父亲 int rank[maxn]//树的高度 //初始化n个元素 void init(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } //查询树的根 int find(int x) { if(par[x]==x) { ... 阅读全文
posted @ 2017-02-01 20:42 超级学渣渣 阅读(161) 评论(0) 推荐(0) 编辑
摘要: //表示节点的数据结构 struct node { int val; node *lch,*rch; }; //插入数值 node *insert(node *p,int x) { if(p==NULL) { node *q=new node; q->val=x; q->lch=q->rch=NULL; ... 阅读全文
posted @ 2017-02-01 20:10 超级学渣渣 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of 阅读全文
posted @ 2017-02-01 19:48 超级学渣渣 阅读(758) 评论(0) 推荐(0) 编辑
摘要: A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run o 阅读全文
posted @ 2017-02-01 17:25 超级学渣渣 阅读(655) 评论(0) 推荐(0) 编辑
摘要: int heap[MAX_N],int sz=0; void push(int x) { int i=sz++; while(i>0) { int p=(i-1)/2;//得到父节点 if(heap[p]=x) break; heap[a]=x; i=a; } heap[i]=x; ... 阅读全文
posted @ 2017-02-01 14:14 超级学渣渣 阅读(232) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-02-01 13:50 超级学渣渣 阅读(0) 评论(0) 推荐(0) 编辑