HNUSTOJ-1675 Morse Code(DFS+字典序搜索)
1675: Morse Code
时间限制: 2 Sec 内存限制: 128 MB
提交: 73 解决: 33
[提交][状态][讨论版]
题目描述
摩尔斯电码(英语:Morse Code)是一种时通时断的信号代码,通过不同的排列顺序来表达不同的英文字母、数字和标点符号。是由美国人萨缪尔·摩尔斯在1836年发明。
输入
仅有一行,由点和划构成的字符串,字符串长度不超过25。
输出
按字母序输出字符串所有可能的译码,每种情况占一行。
样例输入
--.-.
样例输出
GN
GTE
MAE
MEN
METE
MR
QE
TC
TKE
TNN
TNTE
TTAE
TTEN
TTETE
TTR
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<map>
#include<set>
using namespace std; char dic[][]={
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---",
"-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-",
"..-", "...-", ".--", "-..-", "-.--", "--.."
}; int len;
char a[], b[]; bool Strcmp(int cur, char *str){
int len = strlen(dic[cur]);
for(int i = ; i < len; i++)
if(*(str + i) != dic[cur][i]) return false;
return true; }
void DFS(int cur, int l){
if(cur == len) {
for(int i = ; i < l; i++) printf("%c", a[i]);
printf("\n"); return;
}
for(int i = ; i < ; i++){
if(Strcmp(i, b + cur)){
a[l] = 'A' + i;
DFS(cur + strlen(dic[i]), l + );
}
}
}
int main(){
scanf("%s", b);
len = strlen(b);
DFS( , );
}
HNUSTOJ-1675 Morse Code(DFS+字典序搜索)的更多相关文章
- 【LeetCode】804. Unique Morse Code Words 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 set + map set + 字典 日期 题目地 ...
- morse code
morse code,摩斯电码,是一种时通时断的信号代码,通过不同的排列顺序来表达不同的英文字母.数字和标点符号. 摩斯电码,是一种早期的数字化通信形式,但是它不同于现代只使用0和1两种状态的二进制代 ...
- HDU 1241 Oil Deposits DFS(深度优先搜索) 和 BFS(广度优先搜索)
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- 摩尔斯电码(Morse Code)Csharp实现
摩尔斯电码,在早期的"生产斗争"生活中,扮演了很重要的角色,作为一种信息编码标准,摩尔斯电码拥有其他编码方案无法超越的长久生命.摩尔斯电码在海事通讯中被作为国际标准一直使用到199 ...
- HDU 4707 Pet(DFS(深度优先搜索)+BFS(广度优先搜索))
Pet Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissio ...
- Leetcode 804. Unique Morse Code Words 莫尔斯电码重复问题
参考:https://blog.csdn.net/yuweiming70/article/details/79684433 题目描述: International Morse Code defines ...
- [Swift]LeetCode804. 唯一摩尔斯密码词 | Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...
- [LeetCode] Unique Morse Code Words 独特的摩斯码单词
International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...
- (string 数组) leetcode 804. Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...
随机推荐
- 4. ClustrixDB CLX命令详解
Clustrix提供了一个名为clx的实用程序来管理其分布式ClustrixDB数据库. 命令在 /opt/clustrix/bin/ 下面 sudo su - clxm 用户即可使用 clx hel ...
- sql 查询 某字段是否重复
select count(*) from ( select * from 客户 )C GROUP BY 客户编码 select * from ( select count(*)num from ( s ...
- sh_08_石头剪刀布
sh_08_石头剪刀布 # 导入随机工具包 # 注意:在导入工具包的时候,应该将导入的语句,放在文件的顶部 # 因为,这样可以方便下方的代码,在任何需要的时候,使用工具包中的工具 import ran ...
- AttributeError: module 'datetime' has no attribute 'now'
在用时间转化时,一直报AttributeError: module 'datetime' has no attribute 'now', 我用的 import datetime datetime ...
- D. Restore Permutation
D. Restore Permutation 就是给一个n个数的全排,然后bi记录比ai小且在排在ai前面的数的和,求ai 树状数组维护,二分 #include<bits/stdc++.h> ...
- TCP与UDP的对比分析
转自该地址:https://blog.csdn.net/birdie_l/article/details/78067896 TCP: 优点:可靠 稳定 TCP的可靠体现在TCP在传输数据之前,会有三次 ...
- vue 中 event.stopPropagation() 和event.preventDefault() 使用
1.event.stopPropagation()方法 这是阻止事件的冒泡方法,不让事件向document上蔓延,但是默认事件任然会执行,当你掉用这个方法的时候,如果点击一个连接,这个连接仍然会被打开 ...
- Failed to read artifact descriptor for xxx:jar
在MyEclipse中执行Maven的install命令时,报“Failed to read artifact descriptor for xxx:jar ”的错误.这可能是在下载过程中文件出现错误 ...
- STL标准库-容器-set与map
STL标准库-容器-set与multiset C++的set https://www.cnblogs.com/LearningTheLoad/p/7456024.html STL标准库-容器-map和 ...
- 【C++进阶:结构体作为叶节点初始化】
使用C++代码,表示叶节点的结构体初始化,以及使用new进行动态内存分配和赋值 #include <iostream> using namespace std; struct TreeNo ...