07 2013 档案

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4631比赛的时候搜到了最接近点对的求法 Nlog(N) 又估摸着依次插入求的话会TLE 想了想觉得可以先把最近的位置求出来 然后后面的直接不用求了 依次直到减完 又觉得可能会有变态的数据每次最近的都在最后面 没敢写。。后来 发现它出现在题解的方法三中。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 500005 8 #define LL long ... 阅读全文
posted @ 2013-07-31 19:23 _雨 阅读(189) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4630给的题解没看懂。。搜解题报告看 了N久 终于在cui大神的指点下 搞明白咋回事了将1-N中的每个数ai的倍数的位置p求出来 它们任意两个p组成的区间内约数至少为ai 在询问的区间L-R中如果存在这样的区间pi-pj那肯定存在相邻的 然后排好序 相邻的为一个区间l-r保存起来以r从小到大排序 将输入的询问区间进行离线处理 以R由小到大排序 对于每个区间插入r值比R小的区间 求值时以L为下界求到N 其实就是求到R 到R还快了500多ms。 1 #include 2 #include 3 #include . 阅读全文
posted @ 2013-07-31 19:18 _雨 阅读(185) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=3321刚一看题以为要建一颗树 看了下讨论说dfs这里dfs遍历时设的标号很好 一个low一个high 包含了以这一节点为根节点的子树结点的所有标号 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 #define lowbit(x) (x&(-x)) 9 struct node10 {11 int u,v,next;12 }ed[N<<1];13 int head[N],t, 阅读全文
posted @ 2013-07-29 19:41 _雨 阅读(193) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=1195模版题 i写成k了 找了一个多小时没找出来。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 1050 8 #define lowbit(x) (x&(-x)) 9 int n,c[N][N];10 void add(int i,int j,int da)11 {12 int k;13 while(i>t>>n;43 memset(c,0,sizeof(c));44 w... 阅读全文
posted @ 2013-07-29 16:17 _雨 阅读(221) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4619二分图匹配 最小点覆盖 = 最大匹配 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int map[1010][1010]; 7 struct node 8 { 9 int x,y;10 }p[1010],q[1010];11 int n,m,vis[1010],link[1010];12 int judge(int i,int j)13 {14 if(p[i].x>n>>m)42 {4... 阅读全文
posted @ 2013-07-29 14:43 _雨 阅读(183) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=2892记录每个区间端点的左连续及右连续 都是单点更新 用不着向下更新 还简单点找错找了N久 最后发现将s[w 2 #include 3 #include 4 #include 5 using namespace std; 6 #define N 50010 7 int lr[N>1;14 build(l,m,w>1;20 lr[w] = lr[w>1;36 if(p>1;49 if(p=p)58 return lr[w>n>>m)67 {68 build(1,n,1);... 阅读全文
posted @ 2013-07-29 14:33 _雨 阅读(256) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4614线段树的各种操作 写的有点乱 求插入位置是以区间K值的方法求出的 向下更新 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define N 50010 7 int s[N>1; 18 build(l,m,w>1; 49 if(p=r) 57 { 58 if(d) 59 s[w] = r-l+1; 60 else 61 ... 阅读全文
posted @ 2013-07-28 15:12 _雨 阅读(158) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=2352二维逆序数 按一个数排序 转化为1维的 之前用树状数组写过 这次用线段树敲了下 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 32010 8 struct node 9 {10 int x, y;11 }st[N];12 int s[N>1;27 build(l,m,w>1;42 if(p=r)51 {52 return s[w];53 }54 ... 阅读全文
posted @ 2013-07-14 20:32 _雨 阅读(232) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=2482类似于上一篇 这题转化的比较巧妙 将一个点转化为一个矩形(x,y, x+w,y+h),扫描线入值为正 出值为负也就是一根线过去 每进入一个矩形 都更新线上的总值 取一个最大值 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 20010 8 #define LL long long 9 struct node 10 { 11 LL lx,rx,y,s; 12 node()... 阅读全文
posted @ 2013-07-14 19:47 _雨 阅读(241) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=1151http://www.cnblogs.com/kane0526/archive/2013/02/26/2934214.html这篇博客写的不错 主要是图画的不错求面积并 离散化后 通过添加矩形的x方向边 用线段树不断更新(要求的分割开的)矩形的长和宽 1 #include 2 #include 3 #include 4 #include 5 #define maxn 5050 6 using namespace std; 7 struct node 8 { 9 double lx,rx,y;10 int s;11 ... 阅读全文
posted @ 2013-07-14 19:22 _雨 阅读(174) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=2750之前做过类似的题 把一段的左连续最大、最小 右连续最大及最小及中间的连续更新出 就可以算出这段最大的连续和注意不能全部加上 加上一特判 如果最大和是全部数的和就减去这段最小的和 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 struct node 9 {10 int va,lmax,rmin,lmin,rmax,smax,smin;11 }p[N>1;33 bui... 阅读全文
posted @ 2013-07-11 22:00 _雨 阅读(376) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=2886单点更新 初始位置都是1 如果这个人出去 位置变为0 利用线段树求区间k值 k值的计算如下如果这个数值是负的 那么下一个人的就是((k-1+p[id].d)%n+n)%n+1; 如果是正的 下一个人就是(k-1+p[id].d-1)%n+1; 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define N 500010 9 struct node10 {11 char s[12];12... 阅读全文
posted @ 2013-07-11 18:18 _雨 阅读(216) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示