上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 42 下一页
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 = 1000;double sum[maxn<<2];int cover[maxn<<2];double x[maxn];struct seg{ double l,r,h; int flag; seg(){} seg(doub Read More
posted @ 2012-01-21 20:32 Because Of You Views(370) Comments(0) Diggs(0) Edit
跑的好慢啊,看到别人的几百ms,就知道这道题目不能AC了就算数先记在这View Code #include<cstdio>#include<cstring>#include<queue>#include<algorithm>using namespace std;const int M =1010;int map[M][M];int vis[M][M];int dir[8][2]={-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};int r,c;int sx,sy,ex,ey;struct node{ int x,y Read More
posted @ 2012-01-14 06:17 Because Of You Views(290) Comments(0) Diggs(0) Edit
1 a:询问有没有连续长度为a的空位置,插进最左边2 a b :【a,a+b-1】区间清空结点记录的信息:1:区间内最长的连续空位(msum)2:从当前区间的最左端开始的连续空位长度(lsum)3:从当前区间的最右端开始的连续空位长度(往左边数)(rsum)区间的最值就是max(左右子节点最长连续空位的最大值,lsum【rt<<1|1】+rsum[rt<<1])其他就基本上和一般的成段更新,懒惰标记没什么区别了View Code #include<cstdio>#define lson l,m,rt<<1#define rson m+1,r,rt Read More
posted @ 2012-01-14 04:30 Because Of You Views(340) Comments(0) Diggs(0) Edit
题意就不说了有几个值得注意的地方,首先,数据范围太大,要离散化有一个问题就是1 5 5离散化后可能是1 3 2本来应该是1 2 3的,就会出错所以排序的时候加个按关键值排序,值相同时按id递增排序View Code #include<cstdio>#include<algorithm>using namespace std;const int mod=1000000007;const int maxn=100000;struct node{ int num; int id;}a[maxn+10];__int64 dp[maxn+10];int num[maxn+10]; Read More
posted @ 2012-01-12 18:08 Because Of You Views(289) Comments(0) Diggs(0) Edit
时间卡的比较紧,险过,成段更新,懒惰标记 发现define max(a,b)比写个函数来的快,不知为何区间记录三个域最大值、最小值、增加的值如果最大值<P,加上2*c如果最小值>=p,加上c;注意每次别忘了把信息pushdown下来就好了最后只需query()一次View Code #include<cstdio>#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define max(a,b) (a>b?a:b)#define min(a,b) (a<b?a:b)const int ma Read More
posted @ 2012-01-12 11:26 Because Of You Views(342) Comments(0) Diggs(0) Edit
字典树没有清空wrong了一次假设最后所有的字符都要删除,则每个字符至少被删除一次,被打进一次,还有n次的打印现在最后可以剩下一个字符串,则应该剩下最长的那串,可以减少最多的删除操作View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char s[55];int ans;class trie{public : trie* child[27]; trie() { memset(child,0,sizeof(child)); }}root;voi. Read More
posted @ 2012-01-11 19:25 Because Of You Views(290) Comments(0) Diggs(0) Edit
被攻击的次数等于总的攻击次数减去成功防守的次数这道题目其实主要考如何计算成功防守的次数增加一个辅助数组pos【】,记录上次询问后某个点防守到了第几次进攻(第一次进攻都能防守住)每防守住一次,就过t0-1次进攻,继续判断接下来的第t0次进攻有没有包括(即攻击到)询问的点有的人说复杂度是O(n^2),最坏复杂度确实可能是O(q)*O(q/t)log(n),应该是超时边缘,但就是过了,开个挂后速度还不错。。。可能数据不强View Code #include<cstdio>#include<cstring>const int maxn = 20001;int c[maxn];s Read More
posted @ 2012-01-11 11:35 Because Of You Views(869) Comments(0) Diggs(0) Edit
线段树做法http://www.cnblogs.com/wuyiqi/archive/2011/12/21/2295391.html从后往前操作View Code #include<cstdio>#include<cstring>const int maxn = 80001;int a[maxn],c[maxn],ans[maxn],n;int lowbit(int x){ return x&-x;}void update(int x,int d){ for(;x<maxn;x+=lowbit(x)) c[x]+=d;}int sum(int x){ in Read More
posted @ 2012-01-10 12:56 Because Of You Views(234) Comments(0) Diggs(0) Edit
题目抽象:给定最大的覆盖次数k和q条线段对于每条线段判断是否能覆盖在相应区间上使得该区间上最大的覆盖次数<k,输出这些线段的编号有两种做法,一种使用懒惰标记,一种不使用,时间差不多先讲使用懒惰标记的没什么好讲的,在需要更新或查询的时候将信息往下传即可,上代码View Code #include<stdio.h>#include<cstring>#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define mid (l+r)>>1const int maxn = 1000010;i Read More
posted @ 2012-01-09 20:34 Because Of You Views(1831) Comments(1) Diggs(0) Edit
线段树区间染色,判断区间颜色的数目典型的成段更新,懒惰思想View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100010;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int col[maxn<<2];//是否被某种颜色完全覆盖 int sum[maxn<<2];//刚开始想只用一个域来表示,但是怕会分不清楚的,所以 Read More
posted @ 2012-01-09 16:55 Because Of You Views(233) Comments(1) Diggs(0) Edit
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 42 下一页