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

2012年4月29日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1285拓扑排序 小心重边View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=510; 6 int g[N][N],ind[N],n; 7 int topo[N]; 8 bool toposort() 9 {10 for(int i=1;i<=n;i++)11 {12 int u;13 for(u=1;u<=n;u++)14 ... 阅读全文
posted @ 2012-04-29 10:54 Qiuqiqiu 阅读(137) 评论(0) 推荐(0) 编辑

2012年4月28日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1247字典树读入的时候必须用scanf,用gets就错View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=50010; 6 const int SZ=100000,CH=26; 7 int chd[SZ][CH],key[SZ]; 8 int sz=0; 9 char w[N][50];10 int n=0;11 void insert(char *str)1 阅读全文
posted @ 2012-04-28 20:01 Qiuqiqiu 阅读(157) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1880最初的想法直接快排+二分查找为了练习hash就用hash做了View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=100010,MAXH=100003; 6 char w0[N][25],w1[N][85]; 7 int head[2][MAXH],next[2][N]; 8 int n; 9 int hash(char *key)10 {11 unsig 阅读全文
posted @ 2012-04-28 19:02 Qiuqiqiu 阅读(274) 评论(0) 推荐(0) 编辑

2012年4月27日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3635并查集改变一个点的值,同时要改变他儿子的值,用并查集实现View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=10010; 6 int set[N],cnt[N],sum[N]; 7 int find(int x) 8 { 9 if(x==set[x]) return x;10 int t=find(set[x]);11 cnt[x]+=cnt[set.. 阅读全文
posted @ 2012-04-27 15:24 Qiuqiqiu 阅读(146) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3047并查集 记录各点到根的距离View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=50010,md=300; 6 int set[N],sum[N]; 7 int find(int x) 8 { 9 if(set[x]==x) return x;10 int t=find(set[x]);11 sum[x]+=sum[set[x]];12 ret... 阅读全文
posted @ 2012-04-27 14:22 Qiuqiqiu 阅读(183) 评论(0) 推荐(0) 编辑

2012年4月26日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3038好牛的并查集View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=200010; 6 int set[N],sum[N]; 7 int find(int x) 8 { 9 if(x==set[x]) return x;10 int t=find(set[x]);11 sum[x]+=sum[set[x]];12 return set[x]=t;... 阅读全文
posted @ 2012-04-26 21:52 Qiuqiqiu 阅读(135) 评论(0) 推荐(0) 编辑

2012年4月22日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4217View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 typedef __int64 LL; 6 const int N=270000; 7 int c[N]; 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 void add(int x,int p,int maxn)13 {14 for(int i=p;i<=maxn 阅读全文
posted @ 2012-04-22 14:43 Qiuqiqiu 阅读(178) 评论(0) 推荐(0) 编辑

2012年4月19日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2444View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=210; 6 int set[N],g[N][N],n; 7 bool flag; 8 int mat[N],vis[N]; 9 void dfs(int u,int c)10 {11 if(!flag) return;12 for(int v=1;v<=n;v++) if(g[u][v])13 阅读全文
posted @ 2012-04-19 20:55 Qiuqiqiu 阅读(161) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2063来个邻接表的,当然邻接矩阵更简单View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=510, M=1100; 6 int u[M],v[M],next[M],first[N],n; 7 int mat[N]; 8 bool vis[N]; 9 bool find(int ue)10 {11 for(int e=first[ue];e!=-1;e=next 阅读全文
posted @ 2012-04-19 15:46 Qiuqiqiu 阅读(216) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1528View Code 1 #include <stdio.h> 2 #include <string.h> 3 4 const int N=30; 5 int a[N],e[N],n; 6 int mat[N]; 7 bool vis[N]; 8 int val(char *c) 9 {10 int s=0;11 if('2'<=c[0] && c[0]<='9') s=c[0]-'0';12 else s 阅读全文
posted @ 2012-04-19 14:19 Qiuqiqiu 阅读(172) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 20 下一页