CF514C.Watto and Mechanism

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with nn strings. Then the mechanism should be able to process queries of the following type: "Given string ss , determine if the memory of the mechanism contains string tt that consists of the same number of characters as ss and differs from ss in exactly one position".

Watto has already compiled the mechanism, all that's left is to write a program for it and check it on the data consisting of nn initial lines and mm queries. He decided to entrust this job to you.
Watto 是一家零配件商店的老板,最近他接到了一个订单,需要一个能以某种方式处理字符串的机械装置。最初,该装置的内存中装满了 n 个字符串。然后,该机构应能处理以下类型的查询:"给定字符串 s ,判断机构内存中是否包含字符串 t ,该字符串由与 s 相同的字符数组成,且与 s 相差恰好一个位置"。

瓦托已经编译了这个机制,剩下的工作就是为它编写一个程序,并对由 n 个初始行和 m 个查询组成的数据进行检查。他决定把这项工作委托给你。

输入格式

The first line contains two non-negative numbers nn and mm ( 0<=n<=31050<=n<=3·10^{5} , 0<=m<=31050<=m<=3·10^{5} ) — the number of the initial strings and the number of queries, respectively.

Next follow nn non-empty strings that are uploaded to the memory of the mechanism.

Next follow mm non-empty strings that are the queries to the mechanism.

The total length of lines in the input doesn't exceed 61056·10^{5} . Each line consists only of letters 'a', 'b', 'c'.
输入
第一行包含两个非负数 nm(0n31050m3105)n 和 m ( 0 ≤ n ≤ 3·10^5 , 0 ≤ m ≤ 3·10^5 )--分别是初始字符串数和查询次数。
接下来, n 个非空字符串被上传到机制的内存中。

接下来的 m 个非空字符串是对机制的查询。

输入内容的行总长度不超过 61056·10^5 。每行仅由字母'a'、'b'、'c'组成。

输出格式

For each query print on a single line "YES" (without the quotes), if the memory of the mechanism contains the required string, otherwise print "NO" (without the quotes).
输出
对于每个查询,如果机制内存中包含所需字符串,则单行打印"是"(不带引号),否则打印"否"(不带引号)。

输入输出样例

  • 输入#1

    2 3
    aaaaa
    acacaca
    aabaa
    ccacacc
    caaac
    

    输出#1

    YES
    NO
    NO
    
首页