Dominant Species
Time limit1sMemory limit256 MB
For each area, tally the weighted predator sightings and print the unique top scorer or report no dominant species.
- Level
Easy1 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
The Natural Wildlife Federation wants to know the dominant species in several areas of the United States. Its researchers went out and recorded the current population of four predators. The species differ in size, weight, and hunting ability, so each one has a weighted value.
One mountain lion is therefore worth two bobcats, and one wolf is worth three coyotes. A researcher records a sighting by writing B for a bobcat, C for a coyote, M for a mountain lion, and W for a wolf. For example, if the researcher at Saguaro saw 5 wolves, 10 coyotes, 2 bobcats, and no mountain lions, the record is Saguaro WCCCBCCCCWWBCCWWC.
In one record, the score of a species is its population times its value. If exactly one species has the highest score, that species is the dominant species of the area. If two or more species share the highest score, the area has no dominant species.
Process the raw data and report the dominant species of each area.
Input
The first line holds a positive integer n, the number of data sets that follow. Each of the next n lines holds one data set made of two words. The first word is the location and the second word is the sighting record described above. The second word contains no blanks and only the letters B, C, M, and W. Its length does not exceed 100.
Output
For each data set print one of these two sentences.
<x>: The <y> is the dominant species
<x>: There is no dominant species
Replace <x> with the location. Replace <y> with the name of the dominant species, one of Bobcat, Coyote, Mountain Lion, and Wolf. If the area has no dominant species, print the second sentence.