#K10666. Analyzing Mythical Creature Appearance Patterns
Analyzing Mythical Creature Appearance Patterns
Analyzing Mythical Creature Appearance Patterns
This problem involves analyzing the appearance patterns of mythical creatures over a week. For each creature, you are given a string of length 7 that represents whether the creature appeared (1) or did not appear (0) on each day of the week (days 1 through 7). You need to compute the total number of days on which each creature appeared and list the day numbers on which the appearance occurred. The input terminates when a line containing a single hyphen (-
) is encountered.
The task is to output two lines for each creature. The first line should be in the format:
<CREATURE>: <total_appearances>
The second line should be in the format:
Most appearances on: <day1> <day2> ...
If the creature did not appear on any day, the list of days should be empty.
Note: The days are considered in order and correspond to the indices $1,2,3,4,5,6,7$ respectively.
inputFormat
The input consists of multiple lines. Each line (except the last) contains a creature's name and a 7-digit binary string separated by a space. The binary string represents the creature's appearance pattern for each day of the week (where '1' indicates an appearance and '0' indicates absence). The input terminates with a line containing a single hyphen "-".
Example:
DRAGON 1101100 PHOENIX 1111111 UNICORN 1000001 MERMAID 0000111 -
outputFormat
For each creature, output two lines. The first line should print the creature's name and its total number of appearance days in the format:
<CREATURE>: <total_appearances>
The second line should list the days (1-indexed) on which the creature appeared, in the format:
Most appearances on: <day1> <day2> ...
If the creature did not appear on any day, output the second line with an empty list after the colon.
## sampleDRAGON 1101100
PHOENIX 1111111
UNICORN 1000001
MERMAID 0000111
-
DRAGON: 4
Most appearances on: 1 2 4 5
PHOENIX: 7
Most appearances on: 1 2 3 4 5 6 7
UNICORN: 2
Most appearances on: 1 7
MERMAID: 3
Most appearances on: 5 6 7
</p>