poj1731 next_permutation
来源:互联网 发布:泉州数据分析培训 编辑:程序博客网 时间:2024/06/12 03:39
/** * poj1731 字典序(next_permutation) * 其实用DFS也可以,一样用一维的标志位数组就可以标识字母是否出现过了, * 在一级深度遍历完并恢复了v[i]=false之后,while(s[i] == s[i+1]) i++,把连续的相同字母都跳过就可以了, * 而之前第一个字母DFS过的,就已经包含了需要的序列 * 当然,我这里用的next_permutation的方法就不需要这么麻烦 */#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char input[201];int main(){ scanf("%s",input); sort(input,input+strlen(input)); printf("%s\n",input); while(next_permutation(input,input+strlen(input))){ printf("%s\n",input); } return 0;}
0 0
- poj1731 next_permutation
- poj1731(next_permutation+sort进行全排列)
- POJ1731
- POJ1731
- poj1731 - Orders
- POJ1731 Orders
- poj1731 Orders
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- next_permutation
- visudo精确用户赋权(sudo)
- poj1723 排序+中位数
- MATLAB R2009b安装破解
- Android 4.4 Kitkat Phone工作流程浅析(三)__MO(去电)流程分析
- poj1727 排序+二分搜索
- poj1731 next_permutation
- poj1732 DP
- 查找文件夹下特定后缀名的文件,返回列表。
- i386中的状态和控制寄存器
- nodejs总结
- html5本地存储的兼容性写法
- poj1745 0-1DP
- poj1830 高斯消元法
- poj1915 BFS