上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 42 下一页
一个小bug搞了半天,由于没有离散化,线段树的域的空间应该是4*maxn,maxn为x坐标的最大值View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 50000; //maxn 为 x 的最大值(如果离散化了就是矩形的个数*2)int sum[maxn<<2];int cover[ma Read More
posted @ 2012-02-02 19:57 Because Of You Views(302) Comments(0) Diggs(0) Edit
没想出来,参考了网上的做法枚举两个灯之间的最大距离,易知答案至少是这个距离的一半。枚举每个灯,去掉不符合条件的灯,即level值小于当前ans的,这个时间是O(1)的,只是更改一下上下左右灯(如果有)的指向的灯复杂度为输入的复杂度O(n*m)View Code #include<cstdio>#include<cstring>#include<ctype.h>#include<algorithm>using namespace std;const int inf = 100000000;const int maxn = 11111;struct Read More
posted @ 2012-02-01 16:43 Because Of You Views(547) Comments(0) Diggs(0) Edit
PostersTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2061Accepted Submission(s): 455Problem DescriptionTed has a new house with a huge window. In this big summer, Ted decides to decorate the window with some posters to prevent the glare outside. Read More
posted @ 2012-01-31 20:15 Because Of You Views(598) Comments(0) Diggs(0) Edit
iterator lower_bound( const key_type &key ) 函数用法,返回一个迭代器,指向键值>= key的第一个元素。iterator upper_bound( const key_type &key ) 函数用法,返回一个迭代器,指向键值> key的第一个元素。 Read More
posted @ 2012-01-31 20:12 Because Of You Views(225) Comments(0) Diggs(0) Edit
View Code //树状数组 + 简单DP//同hdu 3450,dp的求和操作由树状数组来求执行#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 500010;const int mod = 1000000007;__int64 c[maxn],a[maxn],val[maxn],b[maxn];int tot;int lowbit(int x){ return x&-x;}void update(int x,__in Read More
posted @ 2012-01-31 19:53 Because Of You Views(434) Comments(0) Diggs(0) Edit
先用简单线段树记录当前线段的左右两端下来的线段编号再从上往下dp下来即可具体做法:先按高度升序排序,依次插入各条线段,每次先询问,后插入线段树只有一个域id【x】,表示当前区域被哪个线段完全覆盖View Code #include<cstdio>#include<cstring>#include<ctype.h>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 111 Read More
posted @ 2012-01-31 19:47 Because Of You Views(229) Comments(0) Diggs(0) Edit
直接把hotel那题的代码拿过来,其他的都用stl来做了View Code #include<cstdio>#include<vector>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 55555;int lsum[maxn<<2],rsum[maxn<<2],msum[maxn<<2],cover[maxn<<2];struc Read More
posted @ 2012-01-31 19:33 Because Of You Views(263) Comments(0) Diggs(0) Edit
dp[i][j]表示快的人走到i,慢的人走到j时的最小路程(j<i)从左到右对于每个点要么给走的快的人,要么给走的慢的人初始化dp[i][j]=INF状态转移方程:f[i+1][i]=min{f[i+1][i],f[i][j]+dis[j][i+1]}此前为f[i][j],当前点i+1分配给jf[i+1][j]=min{f[i+1][j],f[i][j]+dis[i][i+1]}此前为f[i][j],当前点i+1分配给i其中0<=j<i最后结果为min(f[n][i]+dis(i,n))其中i<nView Code #include<cstdio>#incl Read More
posted @ 2012-01-29 18:08 Because Of You Views(820) Comments(0) Diggs(1) Edit
需要记录上一次总的区间长度,和这一次的差的绝对值是x轴的增长量,再记录这段区间内共有几段子区间即可算出y轴的增长量同时要增加两个域lbd rbd(布尔型) 分别记录当前区间最左与最右的元素是否被覆盖View Code #include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const int maxn = 22222;#define lson l,m,rt<<1#define rson m+1,r,rt<< Read More
posted @ 2012-01-27 22:30 Because Of You Views(253) Comments(0) Diggs(0) Edit
记录三个域,每次更新相关信息之后传递上来。sum【】:当前节点的总共合法区间(被覆盖至少两次)cover【】:当前节点区间被覆盖次数once【】:区间内被覆盖一次的总量其他的独立思考应该能想出来View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 2222;double sum[maxn<&l Read More
posted @ 2012-01-23 12:49 Because Of You Views(313) Comments(0) Diggs(0) Edit
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 42 下一页