2015年10月5日

摘要: 解题思路:相当经典的一题,回溯,具体细节处理见代码。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 10; 7 int vis[maxn][maxn], dir[4][2] ... 阅读全文
posted @ 2015-10-05 18:41 改写历史,倾尽天下 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 解题思路:打印路径的模板题,有点意思。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn = 5; 6 int mapp[maxn][maxn], dir[4][2] = {1, 0, -1, 0, 0,... 阅读全文
posted @ 2015-10-05 12:55 改写历史,倾尽天下 阅读(147) 评论(0) 推荐(0) 编辑

2015年10月4日

摘要: 解题思路:简单宽搜,关键是剪枝。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 100005; 7 int vis[maxn]; //标记这个点是否走过 8 int n, k... 阅读全文
posted @ 2015-10-04 13:38 改写历史,倾尽天下 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 解题思路:三维数组,简单宽搜,注意细节。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 35; 7 int dir[6][3] = {0, 0, 1, 0, 0, -1, 0... 阅读全文
posted @ 2015-10-04 12:21 改写历史,倾尽天下 阅读(133) 评论(0) 推荐(0) 编辑

2015年10月3日

摘要: 解题思路:混乱了几天,觉得是时候从新开始刷专题了。这题与八皇后问题区别就是k 2 #include 3 #include 4 using namespace std; 5 const int maxn = 10; 6 int vis[maxn], n, k, cnt; 7 char mapp[ma... 阅读全文
posted @ 2015-10-03 14:33 改写历史,倾尽天下 阅读(131) 评论(0) 推荐(0) 编辑

2015年10月1日

摘要: 解题思路:用两个BFS,第一个可以确定某个点着火的时间。第二个BFS搜索路径。 要是J走到某点的时间比火烧到该点的时间短,则他可以走到该点,否则不能。 同时对输入数据处理,更方便搜索。 -1表示该点是墙或者已经走过,不能走。 -2表示该点可以走 0 ~ x表... 阅读全文
posted @ 2015-10-01 12:07 改写历史,倾尽天下 阅读(129) 评论(0) 推荐(0) 编辑

2015年9月25日

摘要: 解题思路:好久没写搜索了,练练手,陶冶情操。不多说,直接贴代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn = 105; 6 int dir[8][2] = {-1, -1, -1, 0, -1,... 阅读全文
posted @ 2015-09-25 22:29 改写历史,倾尽天下 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 解题思路:这是一道简单的概率dp,只要处理好相关的细节就可以了。 dp[d][i]表示走d步时走到i的改概率,具体参考代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 cons... 阅读全文
posted @ 2015-09-25 21:27 改写历史,倾尽天下 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 解题思路:水题,不多说。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 double A[505]; 7 8 int cmp(int x, int y) 9 {10 return x > y;11 ... 阅读全文
posted @ 2015-09-25 12:43 改写历史,倾尽天下 阅读(116) 评论(0) 推荐(0) 编辑

2015年9月24日

摘要: 解题思路:约瑟夫环。具体见代码: 1 #include 2 using namespace std; 3 int n, k, m, vis[24]; //24,向科比致敬,像科比一样努力的活着。 4 5 int go(int p, int d, int t) 6 { 7 while(t... 阅读全文
posted @ 2015-09-24 14:49 改写历史,倾尽天下 阅读(157) 评论(0) 推荐(0) 编辑

导航