2 shunfurh shunfurh 于 2017.01.08 21:18 提问

Obfuscation

Description

It is a well-known fact that if you mix up the letters of a word, while leaving the first and last letters in their places, words still remain readable. For example, the sentence “tihs snetncee mkaes prfecet sesne”, makes perfect sense to most people.

If you remove all spaces from a sentence, it still remains perfectly readable, see for example: “thissentencemakesperfectsense”, however if you combine these two things, first shuffling, then removing spaces, things get hard. The following sentence is harder to decipher: “tihssnetnceemkaesprfecetsesne”.

You’re given a sentence in the last form, together with a dictionary of valid words and are asked to decipher the text.

Input

On the first line one positive number: the number of testcases, at most 100. After that per testcase:

One line with a string s: the sentence to decipher. The sentence consists of lowercase letters and has a length of at least 1 and at most 1 000 characters.

One line with an integer n with 1 ≤ n ≤ 10 000: the number of words in the dictionary.

n lines with one word each. A word consists of lowercase letters and has a length of at least 1 and at most 100 characters. All the words are unique.

Output

Per testcase:

One line with the deciphered sentence, if it is possible to uniquely decipher it. Otherwise “impossible” or “ambiguous”, depending on which is the case.
Sample Input

3
tihssnetnceemkaesprfecetsesne
5
makes
perfect
sense
sentence
this
hitehre
2
there
hello
hitehre
3
hi
there
three
Sample Output

this sentence makes perfect sense
impossible
ambiguous

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.13 23:51
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Obfuscation failed (result=1)
当使用 maven编译项目时,会出现各种各样意向不到的错误. 一个混淆的问题解决方法:mvn clean package -Dproguard.skip=true
关于DBMS_OBFUSCATION_TOOLKIT
http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_obtool.htm DBMS_OBFUSCATION_TOOLKIT DBMS_OBFUSCATION_TOOLKIT enables an application to encrypt data using either the Data Encryption
编译镜像时给apk加混淆
打开混淆开关Android.mk中经常会看到LOCAL_PROGUARD_ENABLED := full这一句,从字面上理解,是开启混淆。如果你以为这样编译出来的apk就已经被混淆了,结果会让你很困惑。将apk里的classes.dex反编译,会看到代码仍然是混淆之前的状态,甚至连文件大小都没有变化。这行语句加不加,效果是一样的。 事实上,系统编译时,如果LOCAL_PROGUARD_ENABLE
obfuscation
obfuscation is important technology.
POI为“Poor Obfuscation Implementation”的首字母缩写,意为“可怜的模糊实现”。
http://baike.baidu.com/link?url=fLnt6B6ydPs33ngPVW8HOuwzt2OoLjYJd36SZmSt64FfL0AGvk9dzrCJZYzK3jGFCpkauTCUJZGlAQTa0Vu9ja
术语:Obfuscation
在软件开发领域,Obfuscation指对代码做模糊处理,使其难于理解、难于反编译。翻译:A. 代码混淆B. 模糊处理 相关的Obfuscator一词的翻译:A. 混淆器B. 模糊处理器
混淆Proguard Reference的使用(一)
本文参考文档位于Android SDK\tools\proguard目录下,如果想更深入的学习,可以查看docs或者examples目录下的内容! 本文先查看这个文档:file:///ANDROID_HOME/tools/proguard/docs/manual/refcard.html 参考文档:http://www.cnblogs.com/royi123/archive/2013/02/2
防止java反编译的一些常用方法
常用的保护技术   由于Java字节码的抽象级别较高,因此它们较容易被反编译。本节介绍了几种常用的方法,用于保护Java字节码不被反编译。通常,这些方法不能够绝 对防止程序被反编译,而是加大反编译的难度而已,因为这些方法都有自己的使用环境和弱点。   隔离Java程序   最简单的方法就是让用户不能够访问到Java Class程序,这种方法是最根本的方法,具体实现有多种方式。例如,开发人员可以将关
Android 代码混淆选项详细说明
Input/Output Options   输入/输出 选项 @filename   Short for '-include filename'. -include filename   递归读取目录中(如果有)文件的 配置:configuration options -basedirectory directoryname 配置文件的目录   directoryname规则见fil
两种免费的Java Obfuscator比较
两种免费的Java Obfuscator比较【2006-04-07 13:34】【】【Matrix】  Java的bytecode很容易通过JAD等反编译工具搞出源代码, 目前最有效的保护方法是obfuscate类名和方法名。注意: 用obfuscate防盗版是根本不可能, 连汇编这种东西都能被破解掉, 破解java代码简直就是小菜。用obfuscate主要是为了保护源代码