摘要: 就是判断有向图中是否有环 由于开始用dfs搜忘记return了 纠结了一下午 还是经虎学长指点 才找到错误递归View Code 1 #include<stdio.h> 2 #include<string.h> 3 int g[101][101],c[101]; 4 int dfs(int u,int n) 5 { 6 int v; 7 c[u] = -1; 8 for(v = 1 ; v <= n ; v++) 9 if(g[u][v])10 {11 if(c[v]<0)12 {13 ... 阅读全文
posted @ 2012-07-21 20:58 _雨 阅读(288) 评论(0) 推荐(0)
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2142View Code 1 #include<stdio.h> 2 #include<string.h> 3 int q[5001]; 4 int d; 5 void inque(int x) 6 { 7 d++; 8 q[d] = x; 9 }10 int main()11 {12 int t,n,m,i,j,k,f[101][101],fg[101],a,b;13 scanf("%d",& 阅读全文
posted @ 2012-07-21 20:28 _雨 阅读(276) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1181一次AC 没什么细节要注意 就是输入正确 加上dfs 可以 了View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct node 4 { 5 char c[101]; 6 int f; 7 }st; 8 st q[1001]; 9 int flag;10 void dfs(int x,int n)11 {12 int i,j;13 if(flag)14 return ;15 ... 阅读全文
posted @ 2012-07-21 19:29 _雨 阅读(240) 评论(0) 推荐(0)
摘要: 堆排序 堆排序利用了大根堆(或小根堆)堆顶记录的关键字最大(或最小)这一特征,使得在当前无序区中选取最大(或最小)关键字的记录变得简单。 (1)用大根堆排序的基本思想 ① 先将初始文件R[1..n]建成一个大根堆,此堆为初始的无序区 ② 再将关键字最大的记录R[1](即堆顶)和无序区的最后一个记录R 阅读全文
posted @ 2012-07-21 09:37 _雨 阅读(328) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1180这题交了7次 悲剧了 前几次 因为把+行想成是左右走了 一直WA 后来看出来了 又把走过的楼梯给标记了 这里的楼梯不能标记因为可以在原地等着楼梯转变 加的时间有可能是2 这样普通队列满足不了最少的先搜 就用优先队列了View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct node 4 { 5 int x,y,num; 6 }st; 7 int f[22][22]; 8 char c[22][22]; 阅读全文
posted @ 2012-07-21 00:02 _雨 阅读(392) 评论(0) 推荐(0)