#P16194. [ROIR 2014 Day 1] Schools 学校
[ROIR 2014 Day 1] Schools 学校
Problem Description
When registering for the Internet Olympiad, all participants fill in an application form, which requires them to write the name of their school. Different participants may write the school name in different ways, such as “Physics and Mathematics School No. ”, “Phys-Math School No. ”, and so on.
The organizers have already collected all the school names filled in by the participants. It is known that the digits in a school name appear only in the school number, and the digits appear exactly once in the school name. This number uniquely determines the school’s ID.
The school ID is a positive integer and does not start with zero.
Please write a program for the Olympiad website to help the organizers count the following information: how many schools have at most five participants, and output the IDs of these schools.
Input Format
The first line contains an integer , representing the number of school names filled in by all participants.
Each of the next lines contains one school name. A school name contains only uppercase and lowercase English letters, digits, and spaces, and its length does not exceed characters.
Output Format
Output an integer in the first line, representing the number of schools whose number of participants is between and (inclusive). Then output lines, each containing one qualifying school ID, in any order.
9
Physics and Mathematics School 18
9ya shkola imeni Pushkina
Lyceum 9
PaMS 18
Gymnasium 42
School 9
Shkola nomer 9
High school 9
School N 9
2
42
18
Hint
In the example, students from three schools registered for the Internet Olympiad: school ID has two students, ID has one student, and ID has six students. Therefore, the school IDs whose number of participants is between and are and .
Scoring
For the testdata worth points, each school ID is a single digit.
For the testdata worth points, each school ID is strictly less than .
For the testdata worth points, each school ID is strictly less than .
Translation source: GPT 4.1 mini.
Translated by ChatGPT 5