103711: [Atcoder]ABC371 B - Taro

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

Description

Score : $200$ points

Problem Statement

In the Kingdom of AtCoder, the eldest son is always given the name Taro. No one else is given the name Taro. The eldest son is the earliest born male child in each family.

There are $N$ families in the Kingdom, and $M$ babies were born. Before the $M$ babies were born, none of the $N$ families had had any babies.

Information about the babies is given in chronological order of their birth.

The $i$-th baby born was born in family $A_i$, and the baby is male if $B_i$ is M, and female if it is F.

Determine for each of the $M$ babies whether the name given is Taro.

Constraints

  • $1\leq N,M\leq 100$
  • $1\leq A_i\leq N$
  • $B_i$ is M or F.
  • All numbers in the input are integers.

Input

The input is given from Standard Input in the following format:

$N$ $M$
$A_1$ $B_1$
$\vdots$
$A_M$ $B_M$

Output

Print $M$ lines.

The $i$-th line $(1\leq i \leq M)$ should contain Yes if the name given to the $i$-th baby is Taro, and No otherwise.


Sample Input 1

2 4
1 M
1 M
2 F
2 M

Sample Output 1

Yes
No
No
Yes

The first baby is the earliest born boy in family $1$, so he is named Taro.

The second baby is not the earliest born boy in family $1$, so he is not named Taro.

The third baby is a girl, so she is not named Taro.

The fourth baby is the earliest born boy in family $2$, so he is named Taro. Note that the third baby is also born in family $2$, but it is the earliest born boy who is named Taro.


Sample Input 2

4 7
2 M
3 M
1 F
4 F
4 F
1 F
2 M

Sample Output 2

Yes
Yes
No
No
No
No
No

Output

得分:200分

问题陈述

在AtCoder王国中,长子总是被命名为Taro。没有其他人会被命名为Taro。 长子是每个家庭中最早出生的男性孩子。

王国中有$N$个家庭,并且有$M$个婴儿出生。在$M$个婴儿出生之前,$N$个家庭中都没有任何婴儿。

婴儿的信息是按照他们出生的时间顺序给出的。

第$i$个出生的婴儿出生在第$A_i$个家庭,如果$B_i$是M,那么这个婴儿是男性,如果是F则是女性。

确定对于每个$M$个婴儿,给定的名字是否是Taro。

约束条件

  • $1\leq N,M\leq 100$
  • $1\leq A_i\leq N$
  • $B_i$是MF
  • 输入中的所有数字都是整数。

输入

输入从标准输入以以下格式给出:

$N$ $M$
$A_1$ $B_1$
$\vdots$
$A_M$ $B_M$

输出

打印$M$行。

第$i$行$(1\leq i \leq M)$应该包含Yes,如果第$i$个婴儿被命名为Taro,否则包含No


示例输入1

2 4
1 M
1 M
2 F
2 M

示例输出1

Yes
No
No
Yes

第一个婴儿是家庭$1$中最早出生的男孩,所以他被命名为Taro。

第二个婴儿不是家庭$1$中最早出生的男孩,所以他没有被命名为Taro。

第三个婴儿是女孩,所以她没有被命名为Taro。

第四个婴儿是家庭$2$中最早出生的男孩,所以他被称为Taro。注意,第三个婴儿也出生在家庭$2$,但是最早出生的男孩被命名为Taro。


示例输入2

4 7
2 M
3 M
1 F
4 F
4 F
1 F
2 M

示例输出2

Yes
Yes
No
No
No
No
No

加入题单

上一题 下一题 算法标签: