A9842 | Watto and Mechanism
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ strings. Then the mechanism should be able to process queries of the following type: "Given string $s$ , determine if the memory of the mechanism contains string $t$ that consists of the same number of characters as $s$ and differs from $s$ 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 $n$ initial lines and $m$ queries. He decided to entrust this job to you.
Watto 是一家零配件商店的老板,最近他接到了一个订单,需要一个能以某种方式处理字符串的机械装置。最初,该装置的内存中装满了 n 个字符串。然后,该机构应能处理以下类型的查询:"给定字符串 s ,判断机构内存中是否包含字符串 t ,该字符串由与 s 相同的字符数组成,且与 s 相差恰好一个位置"。
瓦托已经编译了这个机制,剩下的工作就是为它编写一个程序,并对由 n 个初始行和 m 个查询组成的数据进行检查。他决定把这项工作委托给你。
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 $n$ initial lines and $m$ 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 $n$ and $m$ ( $0<=n<=3·10^{5}$ , $0<=m<=3·10^{5}$ ) — the number of the initial strings and the number of queries, respectively.
Next follow $n$ non-empty strings that are uploaded to the memory of the mechanism.
Next follow $m$ non-empty strings that are the queries to the mechanism.
The total length of lines in the input doesn't exceed $6·10^{5}$ . Each line consists only of letters 'a', 'b', 'c'.
输入
第一行包含两个非负数 $n 和 m ( 0 ≤ n ≤ 3·10^5 , 0 ≤ m ≤ 3·10^5 )$--分别是初始字符串数和查询次数。
接下来, n 个非空字符串被上传到机制的内存中。
接下来的 m 个非空字符串是对机制的查询。
输入内容的行总长度不超过 $6·10^5$ 。每行仅由字母'a'、'b'、'c'组成。
Next follow $n$ non-empty strings that are uploaded to the memory of the mechanism.
Next follow $m$ non-empty strings that are the queries to the mechanism.
The total length of lines in the input doesn't exceed $6·10^{5}$ . Each line consists only of letters 'a', 'b', 'c'.
输入
第一行包含两个非负数 $n 和 m ( 0 ≤ n ≤ 3·10^5 , 0 ≤ m ≤ 3·10^5 )$--分别是初始字符串数和查询次数。
接下来, n 个非空字符串被上传到机制的内存中。
接下来的 m 个非空字符串是对机制的查询。
输入内容的行总长度不超过 $6·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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted