暴力枚举
小丑小丑小丑
这个作者很懒,什么都没留下…
展开
-
洛谷P3654 Fisrt Step
题目链接:First Step 知识点:直线dfs 直线dfs的意思是沿着一条路一直走到底,不会转弯。 这道题里面就是让你向右或者向下直线dfs。 向下dfs void down(int x, int y) { if(满足结束条件) { 做你要做的事情; return; } int newx = x + dir[0][0], newy = y + dir[0][1];//向下 if (newx >= 0 && newx < n && newy &原创 2021-12-17 16:44:30 · 220 阅读 · 0 评论 -
洛谷P1088火星人
题目链接:火星人 知识点 next_permutation的使用。注:C语言里面没有这个函数。 next_permutation是求一个序列的全排列中,比当前序列字典序稍大的一个序列(唯一)。 例如 1 2 3 4 5 的next_permutation是1 2 3 5 4,再来一次next_permutation是1 2 5 3 4. 假若一直进行next_permutation的话,会直到变成 5 4 3 2 1(当前序列字典序最大的情况) 本题题意就是一个序列在全排列中按照字典序的大小来排序,映射成1原创 2021-12-16 23:38:13 · 1013 阅读 · 0 评论 -
洛谷p1036选数
题目链接:选数 知识点:组合型枚举 这里写递归型组合型枚举 递归搜索树如下: 递归组合型枚举模板 void dfs(int u,int start) { if(u == m) { for(int i = 0; i < m; i++) printf("%d ",path[i]); printf("\n"); return; } for(int i = start; i <= n; i++) {原创 2021-12-14 22:39:57 · 239 阅读 · 0 评论