上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页
  2012年8月9日
摘要: Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分别代表学生的数目和操作的数目。学生ID编号分别从1编到N。第二行包含N个整数,代表这N个学生的初始成绩,其中第i个数代表ID为i的学生的成绩。接下来有M行。每一行有一个 阅读全文
posted @ 2012-08-09 11:43 crying_Dream 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 单点增减,区间求和View Code struct Node { int l, r, mid, sum;}node[MAX]; void init(int a, int b, int n)//init(1,n+1,1); { node[n].l=a; node[n].r=b; node[n].mid=(a+b)/2; node[n].sum=0; if(a+1==b) return ; init(a, (a+b)/2; 2*n); init((a+b)/2, b, 2*n+1);}void add(int pos, int v... 阅读全文
posted @ 2012-08-09 11:38 crying_Dream 阅读(115) 评论(0) 推荐(0) 编辑
摘要: http://www.notonlysuccess.com/index.php/segment-tree-complete/ 阅读全文
posted @ 2012-08-09 11:09 crying_Dream 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共有多少人,例如Derek问:“Tidy,马上汇报第3个营地到第10个营地共有多少人!”Tidy就要马上开始计算 阅读全文
posted @ 2012-08-09 08:14 crying_Dream 阅读(221) 评论(0) 推荐(0) 编辑
摘要: DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upper-left corner is (x1, y1) and lower-right cor 阅读全文
posted @ 2012-08-09 08:02 crying_Dream 阅读(204) 评论(0) 推荐(0) 编辑
摘要: int Lowbit(int t){ return t&(-t);}void add(int x, int y){ int i=y; while(x<=n) { y=i; while(y<=n) { c[x][y]++; y+=Lowbit(y); } x+=Lowbit(x); }}int Sum(int x, int y){ int i=y, sum=0; while(x>0) { y=i; while... 阅读全文
posted @ 2012-08-09 07:50 crying_Dream 阅读(612) 评论(0) 推荐(0) 编辑
  2012年8月8日
摘要: DescriptionFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good.Farmer John has N cows (we number the cows from 1 to N). Each of Farmer John's N cows has a range of cl 阅读全文
posted @ 2012-08-08 21:14 crying_Dream 阅读(411) 评论(0) 推荐(0) 编辑
摘要: DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the leve 阅读全文
posted @ 2012-08-08 15:47 crying_Dream 阅读(1419) 评论(0) 推荐(0) 编辑
摘要: int c[N], n; int Lowbit(int t) //求某一点的管辖范围{ return t&(t^(t-1)); //也可以写成 return t&(-t);}int Sum(int end) //求区间和{ int sum = 0; while(end > 0) { sum += c[end]; end -= Lowbit(end); } return sum;}void add(int li, int val) //开始构建一个树状数组, 也可以修改数组{ while(li<=n) { ... 阅读全文
posted @ 2012-08-08 15:36 crying_Dream 阅读(307) 评论(0) 推荐(0) 编辑
  2012年8月7日
摘要: DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. The computers are repaired one by one, and the network gradually 阅读全文
posted @ 2012-08-07 13:46 crying_Dream 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页