#C11299. Categorize Trees
Categorize Trees
Categorize Trees
You are given an integer (n) representing the number of trees and a list of (n) strings where each string is either "delicious" or "sour". Each tree is identified by a 1-indexed identifier. Your task is to split the trees into two categories based on the fruit type:
(\textbf{Delicious trees}): Trees with fruit type "delicious". (\textbf{Sour trees}): Trees with fruit type "sour".
For example, if (n = 6) and the fruit types are provided as follows:
delicious sour delicious sour delicious sour
Then, the output should be two lines where the first line contains the indices of the delicious trees and the second line contains the indices of the sour trees:
1 3 5
2 4 6
Your solution must read from standard input (stdin) and write to standard output (stdout).
inputFormat
The first line contains an integer (n), the number of trees. The second line contains (n) space-separated strings, each either "delicious" or "sour".
outputFormat
Output two lines:
- The first line should list the 1-indexed identifiers of trees with "delicious" fruits separated by spaces. If there are no such trees, output an empty line.
- The second line should list the 1-indexed identifiers of trees with "sour" fruits separated by spaces. If there are no such trees, output an empty line.## sample
6
delicious sour delicious sour delicious sour
1 3 5
2 4 6
</p>