上一页 1 ··· 6 7 8 9 10 11 12 13 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2717基本BFS 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <queue> 5 using namespace std; 6 int N,K; 7 int degree[100002]; 8 queue<int> Q; 9 void bfs()10 {11 while(!Q.empty()){12 int cur=Q.front();13 Q 阅读全文
posted @ 2011-11-29 19:57 linyvxiang 阅读(160) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3356 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 int l1,l2; 5 char x[1002],y[1002]; 6 int resu[1002][1002]; 7 int max(int a,int b) 8 { 9 return a>b?a:b;10 }11 int min(int a,int b)12 {13 return a<b?a:b;14 }15 16 int main()17 {18 阅读全文
posted @ 2011-11-27 22:59 linyvxiang 阅读(182) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1340教训1)按时休息,这一点比什么都重要,休息其实是在为自己争取时间2)头脑保持清醒,不要图省事3)仔细读题4)不要离开笔和纸,自己先拿手算算 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 char str1[12],str2[12]; 5 char str3[12],str4[12]; 6 7 void cp(char *src,char *dst) 8 { 9 int i,j=strlen(sr 阅读全文
posted @ 2011-11-26 18:27 linyvxiang 阅读(240) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1341类似当年浙大上机题目,不过这个明确指出可能有重边,剩下的事情就好做了 1 #include <stdio.h> 2 #define INF 0xfffffff 3 int mat[102][102]; 4 int N,M; 5 int dij(int a,int b) 6 { 7 bool visited[102]; 8 int min_road[102]; 9 int i,j;10 for(i=0;i<N;i++){11 visited[i]=false;12 ... 阅读全文
posted @ 2011-11-26 17:25 linyvxiang 阅读(185) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1339 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <algorithm> 5 using namespace std; 6 int N; 7 typedef struct Team{ 8 char name[102]; 9 int num;10 int punish;11 }Team;12 Team t[100];13 14 bool cmp(Team a,Team 阅读全文
posted @ 2011-11-26 15:29 linyvxiang 阅读(173) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2123 1 #include <stdio.h> 2 int C,N; 3 int main() 4 { 5 scanf("%d",&C); 6 while(C--){ 7 scanf("%d",&N); 8 int i,j; 9 for(i=1;i<=N;i++)10 for(j=1;j<=N;j++){11 printf("%d",i*j);12 if(j... 阅读全文
posted @ 2011-11-26 12:12 linyvxiang 阅读(252) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2212无聊题,打表,吃饭去1 #include <stdio.h>2 int main()3 {4 printf("1\n2\n145\n40585\n");5 } 阅读全文
posted @ 2011-11-26 11:26 linyvxiang 阅读(134) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2101快吃饭了,做点超级简单的 1 #include <stdio.h> 2 int main() 3 { 4 int a,b; 5 while(scanf("%d%d",&a,&b)!=EOF){ 6 if((a+b)%86==0) printf("yes\n"); 7 else printf("no\n"); 8 } 9 return 0;10 } 阅读全文
posted @ 2011-11-26 11:11 linyvxiang 阅读(172) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3984其实是将九度的1335重写了一遍,不过,不小心操作数组时越界了,在队列中没有任何元素时,用gdb调试时,提示有-127个元素,汗。。,然后没有别的什么大问题了。不过不知道为什么,今天写的代码思路很乱,也不再改了。什么叫少了一个人。。。小雨啊。。 1 #include <stdio.h> 2 #include <queue> 3 #include <stack> 4 using namespace std; 5 int maze[7][7]; 6 int degree[7][7]; 7 typedef 阅读全文
posted @ 2011-11-25 16:51 linyvxiang 阅读(168) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1335开始时傻傻的用DFS,不断超时,不断剪枝,仍不断超时,最后用BFS,先是保存路径,最后求路径长,仍超时,无意中翻到算法导论,也是,题目中没让打印路径,直接记录长度即可,于是把代码一改,结果10个数据过5个,这时我不再怀疑算法的问题了,检查了一遍,发现queue<int> Q开成了全局变量,这样一来,如果上次在队列没空之前找到了出口,队列中会遗留结点,导致下一次的数据出错,改过来,AC,看了下榜,用的内存还算少的~indent不太会用,把代码格式化的有些乱,毕竟是从机房那边VC弄过后邮件发过来的,空格什么的 阅读全文
posted @ 2011-11-23 11:32 linyvxiang 阅读(265) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 下一页