CF633C.Spy Syndrome 2

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique.

For a given sentence, the cipher is processed as:

  1. Convert all letters of the sentence to lowercase.
  2. Reverse each of the words of the sentence individually.
  3. Remove all the spaces in the sentence.

For example, when this cipher is applied to the sentence

Kira is childish and he hates losing

the resulting string is

ariksihsidlihcdnaehsetahgnisol

Now Yash is given some ciphered string and a list of words. Help him to find out any original sentence composed using only words from the list. Note, that any of the given words could be used in the sentence multiple times.

在观察了“间谍综合征”(Spy Syndrome)的结果后,亚什(Yash)意识到了自己方法的错误。他现在相信,像西达南特(Siddhant)这样的一流间谍绝不会使用凯撒密码(Caesar cipher)这种基础而古老的加密方式。经过数周对西达南特语句的观察,亚什确定了一种新的密码技术。

对于给定的句子,该密码按如下步骤处理:

  1. 将句子中所有字母转换为小写;
  2. 单独将句子中每个单词反转;
  3. 删除句子中所有空格。

例如,将该密码应用于句子

Kira is childish and he hates losing

所得字符串为

ariksihsidlihcdnaehsetahgnisol

现在亚什得到了一个已加密的字符串以及一个单词列表。请帮助他找出一个原始句子,该句子仅由给定单词列表中的单词组成(单词可重复使用多次)。

输入格式

The first line of the input contains a single integer n (1 ≤ n ≤ 10 000) — the length of the ciphered text. The second line consists of n lowercase English letters — the ciphered text t.

The third line contains a single integer m (1 ≤ m ≤ 100 000) — the number of words which will be considered while deciphering the text. Each of the next m lines contains a non-empty word w__i (|w__i| ≤ 1 000) consisting of uppercase and lowercase English letters only. It's guaranteed that the total length of all words doesn't exceed 1 000 000.

输入的第一行包含一个整数 nn(1≤n≤10 0001 \leq n \leq 10\,000)—— 表示密文的长度。
第二行包含 nn 个小写英文字母 —— 即密文 tt。

第三行包含一个整数 mm(1≤m≤100 0001 \leq m \leq 100\,000)—— 表示在解密过程中需考虑的单词数量。接下来的 mm 行中,每行包含一个非空单词 wiw_i(∣wi∣≤1 000|w_i| \leq 1\,000),且每个单词仅由大小写英文字母组成。保证所有单词的总长度不超过 1 000 0001\,000\,000。

输出格式

Print one line — the original sentence. It is guaranteed that at least one solution exists. If there are multiple solutions, you may output any of those.

输出一行——原始句子。保证至少存在一个解。如果存在多个解,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    30
    ariksihsidlihcdnaehsetahgnisol
    10
    Kira
    hates
    is
    he
    losing
    death
    childish
    L
    and
    Note

    输出#1

    Kira is childish and he hates losing
  • 输入#2

    12
    iherehtolleh
    5
    HI
    Ho
    there
    HeLLo
    hello

    输出#2

    HI there HeLLo

说明/提示

In sample case 2 there may be multiple accepted outputs, "HI there HeLLo" and "HI there hello" you may output any of them.

在样例 2 中,可能存在多个被接受的输出,例如 "HI there HeLLo" 和 "HI there hello",你可以输出其中任意一个。

输入解题思路,AI测评打分。不知道怎么写?

首页