题库练习 Harry Potter and the Sorting Hat
← 上一题 下一题 →

A7973 | Harry Potter and the Sorting Hat

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

As you know, Hogwarts has four houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The sorting of the first-years into houses is done by the Sorting Hat. The pupils are called one by one in the alphabetical order, each of them should put a hat on his head and, after some thought, the hat solemnly announces the name of the house the student should enter.

At that the Hat is believed to base its considerations on the student's personal qualities: it sends the brave and noble ones to Gryffindor, the smart and shrewd ones — to Ravenclaw, the persistent and honest ones — to Hufflepuff and the clever and cunning ones — to Slytherin. However, a first year student Hermione Granger got very concerned about the forthcoming sorting. She studied all the literature on the Sorting Hat and came to the conclusion that it is much simpler than that. If the relatives of the student have already studied at Hogwarts, the hat puts the student to the same house, where his family used to study. In controversial situations, when the relatives studied in different houses or when they were all Muggles like Hermione's parents, then the Hat sorts the student to the house, to which the least number of first years has been sent at that moment. If there are several such houses, the choice is given to the student himself. Then the student can choose any of the houses, to which the least number of first years has been sent so far.

Hermione has already asked the students that are on the list before her about their relatives. Now she and her new friends Harry Potter and Ron Weasley want to find out into what house the Hat will put Hermione.

输入格式

The first input line contains an integer $n$ ( $1<=n<=10000$ ). It is the number of students who are in the list before Hermione. The next line contains $n$ symbols. If all the relatives of a student used to study in the same house, then the $i$ -th character in the string coincides with the first letter of the name of this house. Otherwise, the $i$ -th symbol is equal to "?".

输出格式

Print all the possible houses where Hermione can be sent. The names of the houses should be printed in the alphabetical order, one per line.

输入输出样例

输入 #1
11
G????SS???H
输出 #1
Gryffindor
Ravenclaw
输入 #2
2
H?
输出 #2
Gryffindor
Ravenclaw
Slytherin
C++ 编辑器
输入
输出