#C14439. Ecosystem Evolution Simulation
Ecosystem Evolution Simulation
Ecosystem Evolution Simulation
You are tasked with simulating an ecosystem evolution consisting of three species: Plants, Herbivores, and Carnivores. The simulation proceeds in discrete time steps. In each step, a natural event occurs which may affect the populations of the species. Following the event, the species undergo a series of operations that update their populations.
The operations occur in the following order:
- Apply the event:
- If the event is drought, the Plants' population is reduced by multiplying by \(0.75\).
- If the event is disease, the Herbivores and Carnivores populations are reduced by multiplying by \(0.9\).
- If the event is none, no change occurs.
- Reproduction of Plants: Increase the Plants' population by adding \(\lfloor Plants \times 0.1 \rfloor\) (their reproduction rate is \(0.1\)).
- Herbivores consume food:
- Let \(R = Herbivores_{population} \times FoodConsumption\) where for Herbivores,
FoodConsumption = 10
. - If the available food (the current Plants' population) is at least \(R\), the Herbivores remain the same.
- If not, the Herbivores' population is reduced to \(\left\lfloor Herbivores_{population} \times \frac{availableFood}{R} \right\rfloor\).
- Let \(R = Herbivores_{population} \times FoodConsumption\) where for Herbivores,
- Reproduction of Herbivores: Increase Herbivores' population by \(\lfloor Herbivores \times 0.2 \rfloor\) (reproduction rate is \(0.2\)).
- Carnivores consume food:
- Let \(R = Carnivores_{population} \times FoodConsumption\) where for Carnivores,
FoodConsumption = 5
. - If the available food (the current Herbivores' population) is at least \(R\), the Carnivores remain the same.
- If not, update Carnivores' population to \(\left\lfloor Carnivores_{population} \times \frac{availableFood}{R} \right\rfloor\).
- Let \(R = Carnivores_{population} \times FoodConsumption\) where for Carnivores,
- Reproduction of Carnivores: Increase Carnivores' population by \(\lfloor Carnivores \times 0.15 \rfloor\) (reproduction rate is \(0.15\)).
- Aging: All species age which reduces their populations:
- Plants: New population becomes \(\lfloor Plants \times \left(1-\frac{1}{5}\right) \rfloor\) (lifespan is 5).
- Herbivores: New population becomes \(\lfloor Herbivores \times \left(1-\frac{1}{3}\right) \rfloor\) (lifespan is 3).
- Carnivores: New population becomes \(\lfloor Carnivores \times \left(1-\frac{1}{4}\right) \rfloor\) (lifespan is 4).
Initially, the parameters for the species are fixed as follows:
- Plants: Population = 1000, Reproduction Rate = 0.1, Lifespan = 5, Food Consumption = 0.
- Herbivores: Population = 50, Reproduction Rate = 0.2, Lifespan = 3, Food Consumption = 10.
- Carnivores: Population = 20, Reproduction Rate = 0.15, Lifespan = 4, Food Consumption = 5.
Your task is to simulate the ecosystem for a given number of steps. In each step, you will be provided with an event (one of drought, disease, or none). After processing all the simulation steps, output the final populations of Plants, Herbivores, and Carnivores (in that order, separated by a space).
inputFormat
The first line contains an integer \(T\) representing the number of simulation steps. \(T \ge 1\).
Each of the next \(T\) lines contains a single string representing the event for that step. Each event is one of the following: drought
, disease
, or none
.
Note: The simulation uses fixed initial parameters for the species as described in the problem statement.
outputFormat
Output a single line with three space-separated integers representing the final populations of Plants, Herbivores, and Carnivores, respectively, after simulating all \(T\) steps.
## sample1
none
880 40 9