102362: [AtCoder]ABC236 C - Route Map

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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.

Input

题意翻译

# 题目简述 有 $N$ 个站点按顺序排在一条直线上,第 $i(1\le i\le N)$ 个站点是 $S_i$。 有一辆火车会在其中的 $M(M\le N)$ 个站点停下,第 $j(1\le j\le M)$ 个停下来的站点的名字是 $T_j$。 保证 $T_1=S_1,T_M=S_N$。 对于 $N$ 个站点中的每一个,请判断火车是否在该站点停下。 # 数据范围 >$2≤M≤N≤10^5$ > >$N,M$ 为整数 > >$S_i(1 \le i \le N)$是一个长度在 $[1, 10]$ 之间的小写英文字符串。 > >$S_i\ne S_j(i \ne j)$ > >$T_1=S_1,T_M=S_N$ > >$(T_1,\dots, T_M)$ 是通过移除 $(S_1,\dots, S_N)$ 中的若干个站点且不改变原有顺序得到的。 # 输入格式 第一行包含整数 $N,M$。 第二行包含 $N$ 个字符串 $S_1,S_2,\dots,S_N$。 第三行包含 $M$ 个字符串 $T_1,T_2,\dots,T_M$。 # 输出格式 输出 $N$ 行。如果第 $i(1 \le i \le N)$ 个站点在火车的经停站点列表中,输出 `Yes`,否则输出 `No`。 Translated by @[tianbiandeshenghuo11](/user/752485)

Output

分数: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)$中删除零个或多个字符串并将剩余的字符串按原顺序排列得到的。

输入

输入通过标准输入以以下格式给出:

$N$ $M$
$S_1$ $\ldots$ $S_N$
$T_1$ $\ldots$ $T_M$

输出

打印$N$行。从起点站开始的第$i$行$(1 \leq i \leq N)$应该包含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

特快列车可能会在所有车站停车。

加入题单

算法标签: