Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
AtCoder 鉄道のとある路線には N 個の駅が存在し、始点から終点に向かって i \, (1 \leq i \leq N) 番目の駅の名前は S_i です。
普通列車は全ての駅に止まりますが、急行列車は全ての駅に止まるとは限りません。具体的には、急行列車は M \, (M \leq N) 個の駅にのみ止まり、j \, (1 \leq j \leq M) 番目に止まる駅の名前は T_j です。
ただし、T_1 = S_1 かつ T_M = S_N、すなわち急行列車は始点と終点の両方に止まることが保証されます。
N 個の駅それぞれについて、その駅に急行列車が止まるかどうか判定してください。
制約
- 2 \leq M \leq N \leq 10^5
- N, M は整数
- S_i \, (1 \leq i \leq N) は英小文字のみからなる 1 文字以上 10 文字以下の文字列
- S_i \neq S_j \, (i \neq j)
- T_1 = S_1 かつ T_M = S_N
- (T_1, \dots, T_M) は (S_1, \dots, S_N) から 0 個以上の文字列を選んで取り除き、残った文字列を元の順序で並べることで得られる
入力
入力は以下の形式で標準入力から与えられる。
N M S_1 \ldots S_N T_1 \ldots T_M
出力
N 行出力せよ。i \, (1 \leq i \leq N) 行目には、始点から終点に向かって i 番目の駅に急行列車が止まるなら Yes
、そうでないなら No
と出力せよ。
入力例 1
5 3 tokyo kanda akiba okachi ueno tokyo akiba ueno
出力例 1
Yes No Yes No Yes
入力例 2
7 7 a t c o d e r a t c o d e r
出力例 2
Yes Yes Yes Yes Yes Yes Yes
急行列車が全ての駅に止まることもあります。
Score : 300 points
Problem Statement
There are N stations on a certain line operated by AtCoder Railway. The i-th station (1 \leq i \leq N) from the starting station is named S_i.
Local trains stop at all stations, while express trains may not. Specifically, express trains stop at only M \, (M \leq N) stations, and the j-th stop (1 \leq j \leq M) is the station named T_j.
Here, it is guaranteed that T_1 = S_1 and T_M = S_N, that is, express trains stop at both starting and terminal stations.
For each of the N stations, determine whether express trains stop at that station.
Constrains
- 2 \leq M \leq N \leq 10^5
- N and M are integers.
- S_i (1 \leq i \leq N) is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
- S_i \neq S_j \, (i \neq j)
- T_1 = S_1 and T_M = S_N.
- (T_1, \dots, T_M) is obtained by removing zero or more strings from (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:
N M S_1 \ldots S_N T_1 \ldots T_M
Output
Print N lines. The i-th line (1 \leq i \leq N) should contain Yes
if express trains stop at the i-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.