随笔分类 - 

摘要:题目:http://poj.org/problem?id=1611并查集问题,rank[]记录与根节点的关系,num[]记录树的节点数View Code 1 #include <iostream> 2 #include<cstdio> 3 4 using namespace std; 5 int set[30010]; 6 int rank[30010]; 7 int num[30010]; 8 int find(int x) 9 {10 if(x!=set[x])11 {12 set[x]=find(set[x]);13 }14 retur... 阅读全文
posted @ 2013-01-18 20:37 琳&leen 阅读(122) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3026题意真的很难懂。。。题目大意:一个迷宫,'#'是墙,不可行走,‘ ‘是可行走的,现在题目是要求从s出发把所有的字母(‘A’)连起来的最短路径各个字母的边权用bfs可求:墙不可走,超出矩阵范围不可走,建立任意字母之间最短距离的图最后用prim就可以了注:用getchar会wa,不知道为什么。。。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define inf 3000 5 us 阅读全文
posted @ 2012-12-11 02:13 琳&leen 阅读(201) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1789大意:每个卡车都有自己的编号,由七位字母组成d(to,td) is the distance of the types指t0 和 td卡车编号字母不同的个数,即点t0和点td的权最好得衍生方案是是的总权值最小,即最小生成树用的primView Code #include <iostream>#include<cstdio>#include<cstring>#define inf 0x7fffffffusing namespace std;char str[2005][7];int map[20 阅读全文
posted @ 2012-12-03 20:46 琳&leen 阅读(143) 评论(0) 推荐(0)
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2427View Code 1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <cstdio> 5 #define MAX 20001 6 using namespace std; 7 8 struct node 9 { 10 int li; 11 int num; 12 }st[MAX*4];/ 阅读全文
posted @ 2012-08-27 22:14 琳&leen 阅读(136) 评论(0) 推荐(0)
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2421利用最小生成树求出总权值×2 - 最大的叶子节点所经路径的权值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define inf 0x3f3f3f 5 using namespace std; 6 int b[110][110]; 7 void prim(int n) 8 { 9 int 阅读全文
posted @ 2012-08-22 20:48 琳&leen 阅读(184) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3468代码:View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 __int64 s[400010]; 5 __int64 t[400010];//延迟数组,标记 6 void push(int w) 7 { 8 s[w]=s[w*2]+s[w*2+1]; 9 }10 void pushdown(int w, int d)11 {12 if(t[w])//如果延迟,向下更新13 {14 t[w*2]... 阅读全文
posted @ 2012-08-13 22:01 琳&leen 阅读(109) 评论(0) 推荐(0)
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1500View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 using namespace std; 6 struct node 7 { 8 int flag; 9 node *next[26];10 };11 int num;12 node *build()1 阅读全文
posted @ 2012-08-13 20:36 琳&leen 阅读(137) 评论(0) 推荐(0)
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1075View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<stdlib.h> 5 using namespace std; 6 struct node 7 { 8 int flag; 9 char st[101]; 10 node *next[26]; 11 }; 12 node *build() 13 { 14 int i; 15 n... 阅读全文
posted @ 2012-08-13 20:34 琳&leen 阅读(153) 评论(0) 推荐(0)
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1247View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char str[50010][105]; 6 struct node 7 { 8 int flag; 9 node *next[26];10 };11 node *build()12 {13 int i;14 node *p;15 p=new node;16 ... 阅读全文
posted @ 2012-08-13 20:32 琳&leen 阅读(151) 评论(0) 推荐(0)
摘要:View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<math.h> 4 #include<cstring> 5 #define INF 0x3f3f3f 6 struct node 7 { 8 double x,y,z,r; 9 }ht[105];10 double h[105][105];11 void prim(int n)12 {13 int vis[105];14 int pos,i,j;15 double min;16 double tr[105];17 memse. 阅读全文
posted @ 2012-08-11 17:10 琳&leen 阅读(133) 评论(0) 推荐(0)
摘要:数据结构实验之二叉树的建立与遍历Time Limit: 1000MS Memory limit: 65536K题目描述 已知一个按先序序列输入的字符序列,如abc,,de,g,,f,,,(其中逗号表示空节点)。请建立二叉树并按中序和后序方式遍历二叉树,最后求出叶子节点个数和二叉树深度。输入输入一个长度小于50个字符的字符串。输出输出共有4行:第1行输出中序遍历序列;第2行输出后序遍历序列;第3行输出叶子节点个数;第4行输出二叉树深度。示例输入abc,,de,g,,f,,,示例输出cbegdfacgefdba35View Code 1 #include<stdio.h> 2 #inc 阅读全文
posted @ 2012-07-26 14:13 琳&leen 阅读(320) 评论(0) 推荐(0)