Securing the Barn(dfs)
发布日期:2021-10-16 05:05:12
浏览次数:19
分类:技术文章
本文共 1717 字,大约阅读时间需要 5 分钟。
Securing the Barn
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2304 | Accepted: 1466 |
Description
Farmer John has installed a new security system on the barn and now must issue a valid password to the cows in the herd. A valid password consists of L (3 <= L <= 15) different lower-case characters (from the traditional latin character set 'a'...'z'), has at least one vowel ('a', 'e', 'i', 'o', or 'u'), at least two consonants (non-vowels), and has characters that appear in alphabetical order (i.e., 'abc' is valid; 'bac' is not). Given a desired length L along with C lower-case characters, write a program to print all the valid passwords of length L that can be formed from those letters. The passwords must be printed in alphabetical order, one per line.
Input
* Line 1: Two space-separated integers, L and C * Line 2: C space-separated lower-case characters that are the set of characters from which to build the passwords
Output
* Lines 1..?: Each output line contains a word of length L characters (and no spaces). The output lines must appear in alphabetical order.
Sample Input
4 6a t c i s w
Sample Output
acisacitaciwacstacswactwaistaiswaitwastwcistciswcitwistw
Hint
INPUT DETAILS: Passwords of length 4 chosen from the given six characters
Source
题意:
从六个里选四个字母 需至少1个元音字母,两个辅音字母 然后进行全排列
思路:
搜索,首先对所有字母进行一个排序,然后进行搜索,以每个点作为起点开始搜。
代码:
#include#include #include #include #include using namespace std;int ans,sum;char s[27];int vis[27];//代表某个字母是否访问过int l,c;void dfs(int num,int len,int yuan,int fu){ if(len==l&&yuan>=1&&fu>=2) { for(int i=0;i >l>>c; for(i=0;i >s[i]; vis[i]=0; } sort(s,s+c); //排序 dfs(0,0,0,0); return 0;}
转载地址:https://blog.csdn.net/sinat_37668729/article/details/77072592 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年03月15日 13时37分35秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
cmake qt 添加路径 项目_CMake配置Qt工程
2019-04-21
使用python开发的软件协议_WEB开发——Python WSGI协议详解
2019-04-21
冰点下载器手机版apk_冰点文库下载器
2019-04-21
python信号采集代码_13行代码实现:Python实时视频采集(附源码)
2019-04-21
h5引入json_纯js直接引入json文件
2019-04-21
python格式化字符串总结_Python字符串处理方法总结
2019-04-21
python中true什么意思_python中的bool是什么意思
2019-04-21
jacobian 矩阵意义_Jacobian矩阵和Hessian矩阵的作用是什么?
2019-04-21
c++ jna 数据类型_JNA 使用总结
2019-04-21
python中如何遍历列表并将列表值赋予_python中如何实现遍历整个列表?
2019-04-21
xlnt库如何编译_最新mysql数据库源码编译安装。
2019-04-21
mysql 2003错误 10055_MYSQL无法连接---提示10055错误
2019-04-21
mysql redis缓存层_redis实现缓存的两种方式
2019-04-21
git 改local branch名字_用Git管理Latex写论文的工作流程
2019-04-21
mysql索引篇_MySQL索引篇
2019-04-21
有至少一个用MySQL_Mysql有用的面试题
2019-04-21
mysql select同时update_MySQLSELECT同时UPDATE同一张表
2019-04-21
mysql删除后数据库没变化_mysql之delete删除记录后数据库大小不变
2019-04-21