上一页 1 2 3 4 5 6 7 ··· 10 下一页
摘要: 题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=4358一道很好的搜索题,要注意DFS函数的写法,特别是return的写法。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 char map[105][105]; 6 int a[105][105][4]; 7 int sx,sy,tx,ty,flag,n,m; 8 int px[4][4]= 9 {10 阅读全文
posted @ 2012-04-16 17:26 我们一直在努力 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1080其实这道题用BFS或者DFS都行,也就是二分图 昨晚建图时建成了单向图,唉 还以为算法或者题理解错了呢DFSView CodeBFS(快)View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <queue> 5 using namespace std; 6 int map[105][105]; 7 int pay[105 阅读全文
posted @ 2012-04-13 10:50 我们一直在努力 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2359这题主要在于输入上,处理好了 之后就是约瑟夫环了。多组数据,不过这个的约瑟夫环写的有点不好 会超时的。O(N^2)View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int N=1999; 6 int main() 7 { 8 int k,i,len,kk,t,ans=1,gg; 9 char str1[30006];10 char s 阅读全文
posted @ 2012-04-13 10:27 我们一直在努力 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217题意就是通过货币兑换进行增值。floyd的运用,以前这题却一直不会。唉....View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cmath> 5 using namespace std; 6 char str[35][100]; 7 double map[35][35]; 8 int n,m; 9 int find(char * 阅读全文
posted @ 2012-04-12 11:44 我们一直在努力 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3790题意就不说了 相信都可以看懂,和一般的最短路唯一的不同之处就是加了一个费用限制,在最短路相同时要保证费用最小,所以要增加两个数组分别记录各边之间的费用,和到各点的最小费用,在选择点和更新时要注意 在路相同时要对费用进行判断看是否有必要更新费用。View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using nam 阅读全文
posted @ 2012-04-12 09:46 我们一直在努力 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心 很不错的View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 using namespace std; 6 struct ss { 7 int x,y; 8 }num[1005]; 9 int flag[1005];10 int cmp(ss s,ss t)11 {12 if(s.y==t.y)ret 阅读全文
posted @ 2012-04-10 21:23 我们一直在努力 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050下午没事在看一个博客里的贪心专题,虽然没写,不过想了下思路,思路对的就没看了,没思路的或者不一样的看了看。这道题没什么思路,有的思路写了下不对,就是以结束时间为依据排序,然后每次找尽量多的,这种不对我想可能是因为有一部分是从大号移动到小号的,这样就有重合了。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 阅读全文
posted @ 2012-04-10 20:00 我们一直在努力 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1421这是道很久以前的遗留问题了,当时想的那种方法没问题就是老wa,就放下了。 昨晚就又用那种方法了,结果wa,队友指出了这种方法的错误之处,现在想想确实是不全面的。这是到dp题,dp方程是用dp[i][j]表示从前i个人中选出来j对时的最小值,dp[i][j]=min{dp[i-1][j],dp[i-2][j-1]+(a[i]-a[i-1])*(a[i]-a[i-1])} 前面一个表示不选第i个数,后面表示选第i个数。View Code 1 #include <iostream> 2 阅读全文
posted @ 2012-04-06 11:54 我们一直在努力 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3177这道题跟3352十分相似,只是有重边的,再输入的过程中处理下就可以了。View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int MAX=5005; 6 struct ss { 7 int x; 8 int next; 9 }edge[MAX*3]; 10 11 int degree[MAX]; 12 int head[MAX]; 1. 阅读全文
posted @ 2012-04-03 19:52 我们一直在努力 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1556这是一道很好的计算几何和图论的综合题,贵在建图,哪些点之间可以连线,只有当两点之间没有墙时才可以,怎么判断呢 只用把墙的x坐标带入两点的直线中看y坐标是否在墙上就可以了。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cmath> 5 using namespace std; 6 const int MAX=20; 7 const int MMAX=80; 阅读全文
posted @ 2012-04-03 13:52 我们一直在努力 阅读(345) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 10 下一页