#K39492. Counting Gas Stations
Counting Gas Stations
Counting Gas Stations
You are given a route which is divided into several sections. Each section is represented by a string where the character G
denotes a gas station and -
denotes the absence of one. Your task is to count the number of gas stations in each section and output the results in a formatted way.
The output for each section should be in the format: Section i: x gas stations, where i
is the section index starting from 1 and x
is the count of gas stations in that section.
It is guaranteed that the input follows the given format. Use standard input and output to solve this problem.
inputFormat
The first line contains an integer n
representing the number of sections.
The following n
lines each contain a string that represents a section of the route. Each string consists of characters 'G' and '-' only.
outputFormat
Output n
lines. The i-th line should be in the format:
Section i: x gas stations
where i
is the section number (starting from 1) and x
is the count of 'G' in that section.
5
--G--
-G---G
--
G--G-GG
--G-
Section 1: 1 gas stations
Section 2: 2 gas stations
Section 3: 0 gas stations
Section 4: 4 gas stations
Section 5: 1 gas stations
</p>