#abc236c. C - Route Map

C - Route Map

Score : 300300 points

问题描述

在AtCoder铁路公司运营的一条特定线路上有NN个车站。从起点站开始的第ii个车站(1iN1 \leq i \leq N)被命名为SiS_i

普通列车会在所有车站停车,而特快列车则可能不停靠所有车站。具体来说,特快列车仅在MM个车站(MNM \leq N)停靠,其中第jj个停靠站(1jM1 \leq j \leq M)为名为TjT_j的车站。这里保证了T1=S1T_1 = S_1TM=SNT_M = S_N,即特快列车在起始站和终点站都会停车。

对于这NN个车站中的每一个,请确定特快列车是否在该车站停靠。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN stations on a certain line operated by AtCoder Railway. The ii-th station (1iN)(1 \leq i \leq N) from the starting station is named SiS_i.

Local trains stop at all stations, while express trains may not. Specifically, express trains stop at only M(MN)M \, (M \leq N) stations, and the jj-th stop (1jM)(1 \leq j \leq M) is the station named TjT_j.
Here, it is guaranteed that T1=S1T_1 = S_1 and TM=SNT_M = S_N, that is, express trains stop at both starting and terminal stations.

For each of the NN stations, determine whether express trains stop at that station.

Constrains

  • 2MN1052 \leq M \leq N \leq 10^5
  • NN and MM are integers.
  • SiS_i (1iN)(1 \leq i \leq N) is a string of length between 11 and 1010 (inclusive) consisting of lowercase English letters.
  • SiSj(ij)S_i \neq S_j \, (i \neq j)
  • T1=S1T_1 = S_1 and TM=SNT_M = S_N.
  • (T1,,TM)(T_1, \dots, T_M) is obtained by removing zero or more strings from (S1,,SN)(S_1, \dots, S_N) and lining up the remaining strings without changing the order.

Input

Input is given from Standard Input in the following format:

NN MM

S1S_1 \ldots SNS_N

T1T_1 \ldots TMT_M

Output

Print NN lines. The ii-th line (1iN)(1 \leq i \leq N) should contain Yes if express trains stop at the ii-th station from the starting station, and No otherwise.

Sample Input 1

5 3
tokyo kanda akiba okachi ueno
tokyo akiba ueno

Sample Output 1

Yes
No
Yes
No
Yes

Sample Input 2

7 7
a t c o d e r
a t c o d e r

Sample Output 2

Yes
Yes
Yes
Yes
Yes
Yes
Yes

Express trains may stop at all stations.

update @ 2024/3/10 10:13:33

}