Bryak
InterviewTime limit2sMemory limit1024 MB
Given containers with volumes and concentrations and a list of pours between them, find the final volume and concentration of each container.
- Level
Easy3 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Statement
Эй, Брейн, чем мы будем заниматься сегодня вечером?
Тем же, чем и всегда, Пинки... Попробуем завоевать мир!
Пинки и Брейн.
Two extremely clever mice escaped from their cage in a very secret laboratory and decided to take over the world. To do so, they broke into the storage room, where several containers held a solution of a top-secret substance. The containers differed in volume and concentration.
To get a solution of the concentration they needed, the mice poured some liquid from one container into another. Just as they obtained the desired solution, guards arrived and the mice had to flee.
The surveillance cameras recorded everything that happened in the storage room. The scientists who work in this laboratory want to know what the mice were trying to do, so they will use the recording of the mice's actions to determine the concentration of the solution in each container.
Input
The first line contains an integer , the number of containers in the storage room (). Each of the next lines contains two integers and separated by a space, where is the volume of liquid in the -th container in liters and is its concentration in percent (, ). An empty container has a concentration of zero.
The next line contains an integer , the number of operations the mice performed (). Each of the next lines contains three integers , , and (, , ). This means that liters were poured from container into container . It is guaranteed that container holds at least liters of liquid at that moment. All containers are large enough to hold any volume of liquid.
Output
After all the pours, print the volume and concentration of the solution in each container, in the same format as the input. The concentration of each liquid must differ from the correct value by no more than percent.