上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页

2014年3月6日

hdu 1166 树状数组(线段树)

摘要: 敌兵布阵Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35307Accepted Submission(s): 14974Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人 阅读全文

posted @ 2014-03-06 20:24 雄.. 阅读(170) 评论(0) 推荐(0)

hdu 3874 树状数组

摘要: NecklaceTime Limit: 15000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2447Accepted Submission(s): 865Problem DescriptionMery has a beautiful necklace. The necklace is made up of N magic balls. Each ball has a beautiful value. The balls with the same beautiful v 阅读全文

posted @ 2014-03-06 19:55 雄.. 阅读(146) 评论(0) 推荐(0)

2014年3月5日

hdu 1189 并查集

摘要: Farm IrrigationTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4802Accepted Submission(s): 2073Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. W... 阅读全文

posted @ 2014-03-05 22:00 雄.. 阅读(220) 评论(0) 推荐(0)

hdu 1272 并查集

摘要: 题目大意:给一个图,不能出现环,而且只能有一个联通子图。好惆怅,又是爆栈又是wrong answer的。#include#includeusing namespace std;const int maxn=100005;int f[maxn],ans;bool v[maxn];void init(){for(int i=1;ifb) f[fa]=fb; else f[fb]=fa;}int main(){ int a,b,i,sum; while(scanf("%d %d",&a,&b) && !(a==-1 && b==-1 阅读全文

posted @ 2014-03-05 21:02 雄.. 阅读(164) 评论(0) 推荐(0)

hdu 1856 并查集

摘要: More is betterTime Limit: 5000/1000 MS (Java/Others)Memory Limit: 327680/102400 K (Java/Others)Total Submission(s): 11865Accepted Submission(s): 4395Problem DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex,the more boys come, the bett... 阅读全文

posted @ 2014-03-05 19:09 雄.. 阅读(299) 评论(0) 推荐(0)

2014年3月4日

hdu 1232 并查集

摘要: #include#includeusing namespace std;const int maxn=1005;int f[maxn];bool v[maxn];int findset(int x){ return f[x] != x ? f[x]=findset(f[x]) : x;}void merge(int a,int b){ int fa=findset(a); int fb=findset(b); if(fa!=fb) f[fa]=fb;}int main(){ int n,m,i,a,b,ans; while(scanf("%d",&n),n) ... 阅读全文

posted @ 2014-03-04 22:05 雄.. 阅读(121) 评论(0) 推荐(0)

uva 11235 RMQ范围最大值

摘要: 题目大意:给一个整数上升序列,对于一系列询问区间(i,j),回答这段区间出现次数最多值所出现的次数。分析:一个上升序列,相同的值聚集在一起,把相同的值的区间看作一个整体,假设这样的整体有n个,把他们编号。num[p]表示原下标下的数所在段的编号,left[p]、right[p]表示所在段原下标的左右端点位置。编号后的数组用RMQ求范围最大值。对于询问的区间(L,R)在编号后的数组中以以下三个部分的最大值:从L到L所在段的结束处的元素个数(即right[L]-L+1)、从R所在段的开始处到R处的元素的个数(即R-left[R]+1)、中间第num[L]+1段到num[R]-1段的最大值(用RMQ 阅读全文

posted @ 2014-03-04 20:52 雄.. 阅读(243) 评论(0) 推荐(0)

2014年2月25日

LA 4329 树状数组

摘要: N(3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve their skill rank, they often compete with each other. If two players want to compete, they must choose a referee among other ping pong players and hold th 阅读全文

posted @ 2014-02-25 16:32 雄.. 阅读(215) 评论(0) 推荐(0)

2014年2月24日

LA 并查集路径压缩

摘要: 题目大意:有n个节点,初始时每个节点的父亲节点都不存在。有两种操作I u v:把点节点u的父亲节点设为v,距离为|u-v|除以1000的余数。输入保证执行指令前u没有父亲节点。E u:询问u到根节点的距离。分析:并查集加路径压缩。#include#include#include#includeusing namespace std;const int maxn=20010;int f[maxn],d[maxn];int findset(int x){ if(f[x] !=x) { int root=findset(f[x]); d[x]+=d[f[x]]... 阅读全文

posted @ 2014-02-24 20:55 雄.. 阅读(148) 评论(0) 推荐(0)

LA 3644 简单并查集

摘要: 题目大意:有一些简单的化合物,每个化合物由两种元素组成,把这些化合物按顺序装车,若k个化合物正好包含k种元素,那么就会爆炸。避免爆炸,有些化合物就不能装车。求有多少个不能装车。题目分析:若k个化合物正好包含k种元素,那么就会爆炸。我们把每种元素看成一个顶点,每种化合物看成一条边,若有环存在的时候正好是爆炸的情况,所以避免成环记录不能放的数量就行了。#include#includeusing namespace std;const int maxn=100010;int f[maxn];int findset(int x){ return f[x]==x?x:f[x]=findset(f[x]) 阅读全文

posted @ 2014-02-24 17:07 雄.. 阅读(299) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页

导航