Official

D - Taro Editorial by en_translator


Maintain a flag to manage whether each family had had Taro already. The flags are initialized with False.

Inspect the babies in order. If the baby is a girl, print No, and nothing more is required.

If the baby is a boy, check the flag of his family. If the flag is False, print Yes, and set the flag to True. If the flag is already True, print No.

The operations so far can be implemented with for statements, if statements, and arrays.

Sample code (Python):

n, m = map(int, input().split())
taro_exist = [False for i in range(n)]
for i in range(m):
    a, b = input().split()
    a = int(a) - 1
    if b == 'F' or taro_exist[a]:
        print('No')
    else:
        taro_exist[a] = True
        print('Yes')

posted:
last update: