上一页 1 ··· 40 41 42 43 44
摘要: 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2138 第一个搜索,我也不知道这到底是BFS还是DFS。。。。那个全局标记变量没有初始化,WA了一次。。。本来多么美好的一个开始就这样破坏了。。 1 #include <stdio.h> 2 #include <string.h> 3 int p[1001][1001],o[1001],z; 4 void dfs(int n,int x) 5 { 6 int i; 7 o[x] = 1; 8 if(x == 1 阅读全文
posted @ 2012-05-28 21:38 Naix_x 阅读(203) 评论(0) 推荐(0)
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1435这个题做的好没状态。上几天刷的高精度都白刷了啊。。。首先代码除法和取余以前都做过,还要查看以前的代码,模板还打错。。DEBUG好久,然后由于这个破精度(还是看的队友的解题报告),错了好几次,开始数组RE一一次,忘记0的情况(高精度老问题),还要有那个破空格,终于6A。。。基本上这个题所有的trick我都踩了。 1 #include <stdio.h> 2 阅读全文
posted @ 2012-05-28 20:02 Naix_x 阅读(402) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2137 后序遍历没啥好说的,递归就好,层次遍历有点BFS的感觉。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 struct tree 5 { 6 char l; 7 struct tree *left,*right; 8 }; 9 struct tree *build(char *p,char *s,int n 阅读全文
posted @ 2012-05-28 19:07 Naix_x 阅读(204) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2136 这个题看书+问学长.2A.#include <stdio.h>#include <string.h>#include <stdlib.h>int num=-1;char str[51];struct tree{ char lat; struct tree *left; struct tree *right;};struct tree *build()//建树{ struct tree *p; 阅读全文
posted @ 2012-05-28 16:53 Naix_x 阅读(208) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2141 这个题听虎哥给讲的,开始自己想的时候老是以为BFS就必须得用递归,这个题的思路没有想象的那么复杂啊。#include<stdio.h>#include<string.h>int p[101][101],ans[101],o[101];int main(){ int a,b,c,d,i,j,k,m,n; scanf("%d",&a); while(a--) { memset(a 阅读全文
posted @ 2012-05-27 19:09 Naix_x 阅读(194) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2129最裸的并查集。。模板代码,好久没打过了。#include<stdio.h>int p[1001];int find(int x){ int a=x; while(p[a]!=a) a=p[a]; return a;}void mermge(int x,int y){ int x1=find(x),y1=find(y); if(x1!=y1) p[x1]=y1;}int main(){ int... 阅读全文
posted @ 2012-05-27 17:25 Naix_x 阅读(199) 评论(0) 推荐(0)
摘要: 坑爹的百度空间升级之后,成那个熊样了。。。所以,转战博客园。题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1291 给出先序遍历和中序遍历,求后序遍历。代码参考白书上的。。 思路:先序遍历中第一个肯定是根节点,找到在此节点在中序遍历的位置,则左边为左子树,右边为右子树。递归下去,用一个字符串,存下后序遍历的过程。#include<stdio.h>#include<string.h>void build(int n,char *s1,char *s2,char 阅读全文
posted @ 2012-05-27 16:43 Naix_x 阅读(186) 评论(0) 推荐(0)
上一页 1 ··· 40 41 42 43 44