Qiuqiqiu  
不管道路多么崎岖坎坷,我永远不停下追逐梦想的脚步!
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页

2012年2月28日

摘要: http://poj.org/problem?id=3468成段增减,区间求和View Code 1 #include <cstdio> 2 using namespace std; 3 const int N=100000; 4 struct segtree 5 { 6 int l,r; 7 long long s,a; 8 int m() {return (l+r)>>1;} 9 void add(long long x) {s+=x*(r-l+1); a+=x;}10 }st[4*N];11 void pushup(int rt)12 {13 s... 阅读全文
posted @ 2012-02-28 15:49 Qiuqiqiu 阅读(122) 评论(0) 推荐(0) 编辑

2012年2月27日

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3574求逆序对归并排序O(nlogn),《算法竞赛入门经典》P144View Code 1 //zoj 3574 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <string.h> 5 const int N=30100; 6 struct yy 7 { 8 int l,r; 9 }y[N];10 int a[N],b[N];11 int cmp(const void *a, 阅读全文
posted @ 2012-02-27 08:06 Qiuqiqiu 阅读(245) 评论(0) 推荐(0) 编辑

2012年2月17日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1429BFS + 状态压缩View Code 1 #include <cstdio> 2 #include <cctype> 3 #include <queue> 4 using namespace std; 5 const int N=25; 6 const int dx[4]={0,1,0,-1}; 7 const int dy[4]={1,0,-1,0}; 8 char maze[N][N]={0}; 9 int vis[1100][N][N];10 int n,m, 阅读全文
posted @ 2012-02-17 21:28 Qiuqiqiu 阅读(540) 评论(0) 推荐(0) 编辑

2012年2月16日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2795View Code 1 //2795 2 #include <stdio.h> 3 const int N=200010; 4 int st[N*4]; 5 int h,w; 6 void newup(int rt) 7 { 8 st[rt]=st[rt*2]>st[rt*2+1]?st[rt*2]:st[rt*2+1]; 9 }10 void build(int l,int r,int rt)11 {12 st[rt]=w;13 if (l==r) return;14 ... 阅读全文
posted @ 2012-02-16 16:43 Qiuqiqiu 阅读(129) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1394View Code 1 //1394 2 #include <stdio.h> 3 const int N=5010; 4 int st[4*N],a[N]; 5 void newup(int rt) 6 { 7 st[rt]=st[rt*2]+st[rt*2+1]; 8 } 9 void build(int l,int r,int rt)10 {11 if (l==r)12 {13 st[rt]=0;14 return;15 }16 ... 阅读全文
posted @ 2012-02-16 15:04 Qiuqiqiu 阅读(123) 评论(0) 推荐(0) 编辑

2012年2月14日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1698刚开始学线段树,代码差不多是抄的View Code 1 //1698 2 #include <stdio.h> 3 const int N=100010; 4 int st[4*N],co[4*N]; 5 void newup(int rt) 6 { 7 st[rt]=st[rt*2]+st[rt*2+1]; 8 } 9 void newdown(int rt,int cnt)10 {11 if (!co[rt]) return;12 co[rt*2]=co[rt*2+1]=c... 阅读全文
posted @ 2012-02-14 21:57 Qiuqiqiu 阅读(171) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1754刚开始学线段树View Code 1 //hdu 1754 2 #include <stdio.h> 3 const int N=200000; 4 int st[4*N]; 5 int max(int a,int b) 6 { 7 return a>b?a:b; 8 } 9 void update(int rt)10 {11 st[rt]=max(st[rt*2],st[rt*2+1]);12 }13 void build(int l,int r,int rt)14 {15 ... 阅读全文
posted @ 2012-02-14 20:06 Qiuqiqiu 阅读(116) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1166开始学线段树,代码基本上是抄的View Code 1 //hdu 1166 2 #include <stdio.h> 3 const int N=50010; 4 int st[4*N],n; 5 void build(int l,int r,int rt) 6 { 7 if (l==r) 8 { 9 scanf("%d",&st[rt]);10 return;11 }12 int m=(l+r)/2;13 build(l,m,r... 阅读全文
posted @ 2012-02-14 19:05 Qiuqiqiu 阅读(117) 评论(0) 推荐(0) 编辑

2012年2月12日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2531BFSView Code 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 const int N=110; 6 const int dx[4]={0,1,0,-1}; 7 const int dy[4]={1,0,-1,0}; 8 char maze[N][N]; 9 int vis[N][N];10 int px[10010],py[10010] 阅读全文
posted @ 2012-02-12 21:13 Qiuqiqiu 阅读(343) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1180BFSView Code 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 const int N=100; 6 const int dx[4]={0,1,0,-1}; 7 const int dy[4]={1,0,-1,0}; 8 char maze[N][N]; 9 int vis[N][N][2];10 int n,m,p,t;11 struc 阅读全文
posted @ 2012-02-12 10:33 Qiuqiqiu 阅读(404) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页