上一页 1 ··· 57 58 59 60 61 62 63 64 65 ··· 71 下一页
摘要: 线段树 单点更新http://acm.hdu.edu.cn/showproblem.php?pid=1166View Code 1 #include<stdio.h> 2 #include<string.h> 3 int sum[1000001]; 4 void push(int w) 5 { 6 sum[w] = sum[2*w]+sum[2*w+1];//更新节点值 7 } 8 void build(int l,int r,int w) 9 {10 if(l==r)11 {12 scanf("%d",&sum[w]);13 retu... 阅读全文
posted @ 2012-07-26 09:26 _雨 阅读(156) 评论(0) 推荐(0) 编辑
摘要: http://dongxicheng.org/structure/segment-tree/线段树,也叫区间树,是一个完全二叉树,它在各个节点保存一条线段(即“子数组”),因而常用于解决数列维护问题,它基本能保证每个操作的复杂度为O(lgN)。线段树的基本操作主要包括构造线段树,区间查询和区间修改。struct node{ int ld,rd;//左右边界 node *lc,*rc;//左右孩子 int key;//信息域 如RMQ问题中,信息域中存储的是区间最大值};建树//空树的建立,内含key值的初始化; //一般在主函数中首先调用 Node* root= buildt... 阅读全文
posted @ 2012-07-25 17:25 _雨 阅读(231) 评论(2) 推荐(0) 编辑
摘要: 百练2981 http://poj.grids.cn/practice/2981/View Code 1 #include<stdio.h> 2 #include<string.h> 3 int num[301]; 4 int main() 5 { 6 int i,j,f = 0,f1; 7 char c1[201],c2[201]; 8 gets(c1); 9 gets(c2);10 i = strlen(c1)-1;11 j = strlen(c2)-1;12 int g = 0;13 while(i>=0&&j>=0)14... 阅读全文
posted @ 2012-07-25 16:32 _雨 阅读(211) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1135好繁琐的一道模拟题 细节很重要 编译错误一次 把字符串结尾写错WA一次 多了getchar()WA一次 多了以空格PE一次 最后AC...3个多小时用了一下map map还是很方便的View Code 1 #include <iostream> 2 #include<map> 3 #include<stdio.h> 4 #include&l 阅读全文
posted @ 2012-07-25 10:44 _雨 阅读(317) 评论(2) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1251将每次走过得字母统计数量 查找的时候输出字母数量的最小值View Code 1 #include<stdio.h> 2 #include<iostream.h> 3 #include<string.h> 4 struct node 5 { 6 int count; 7 node *next[27]; 8 node() 9 {10 count = 0;11 memset(next,NULL,sizeof(next));12 }13 ... 阅读全文
posted @ 2012-07-24 20:59 _雨 阅读(189) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=10941A 这题下午想了好久 一直没调出来 由于是边输入边拓扑排序 入度改变之后下次再排会出错 晚上回来想到这一点 每次全复制一遍 只对入度进行操作 不进行改变这个题要 判断三种情况一种是有环在给出几种关系时出现矛盾二是在给出几种关系时 n个数已经排好了序三是输完还是无法排出一种序 这是属于拓扑排序不唯一的情况 也就是同时有多个结点出现的入度为0View Code 1 #include 2 #include 3 int f[100],g[50][50],kk[30],q[50]; 4 int topo(int n,int m) ... 阅读全文
posted @ 2012-07-24 19:19 _雨 阅读(312) 评论(4) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2094其实这题也不算是拓扑排序了 只需要判断最开始入度是否唯一就可以了 如果是0 肯定有环了 不是0 会有多个冠军也不对View Code 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int de[1001]; 7 int main() 8 { 9 int i,j,k,g,n,fg;10 string s1,s2;11 while(cin>>n)12 {13 if(!... 阅读全文
posted @ 2012-07-24 16:59 _雨 阅读(196) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2632好繁琐的一道模拟题 对着测试数据改了将近三个小时才过View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int i,j,t,n,m,a,b,c[101],f[101][101],x[101],y[101],xi,yi,cs1,cs2,crash; 6 char ci,c1; 7 scanf("%d",&t); 8 while(t--) 9 { 10 scanf("%d%d".. 阅读全文
posted @ 2012-07-24 15:31 _雨 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 第一次做 移动不给力啊 WLAN连了不下10次 第一题写完再那无奈的等了20分钟 WLAN艰难的以非常低的信号给连了几分钟 交完又掉了D题不难 就是数据类型用错了A. Dubsteptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Rece 阅读全文
posted @ 2012-07-24 01:42 _雨 阅读(333) 评论(2) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3278三次RE 以为是队列开小了 一直加大队列 忘记是标记数组的事了 改了判断条件 觉得队列不用开那么大 WA。。又开到100W AC..View Code 1 #include<stdio.h> 2 #include<string.h> 3 struct node 4 { 5 int x,num; 6 }q[1000001]; 7 int f[1000010]; 8 int p,d; 9 int main()10 {11 int i,j,n,k,flag = 0;12 scanf("%d%d", 阅读全文
posted @ 2012-07-23 20:52 _雨 阅读(159) 评论(0) 推荐(0) 编辑
上一页 1 ··· 57 58 59 60 61 62 63 64 65 ··· 71 下一页