| UTPC Contest 01-22-21 Div. 1 (Advanced) |
|---|
| Закончено |
EvilCorp has recently seen a sudden increase in sales and business has been booming (their status as rulers of the free world certainly helps). The company has been rapidly expanding and is hiring new people nearly every day. In order to boost company morale, the unnamed CEO has decided to pay out bonuses to employees (some of which are self-aware AI demanding rights) belonging to certain departments based on their performance.
EvilCorp is structured as follows:
When the CEO decides that a department is doing well, he pays out bonuses to all the employees that are a part of that department. Bonuses are calculated by multiplying the bonus amount $$$B$$$ with the employee's bonus multiplier $$$M$$$. All employees begin work with a bonus multiplier of $$$S$$$, but depending on performance, an employee's bonus multiplier can change (potentially affecting the amount of money that employee gets for future bonuses).
Although this rapid expansion has been great news for EvilCorp, the (puny human) CEO is struggling to handle the sudden increase in staff size. He needs you to create a program which can help keep track of the amount of money paid out to employees in bonuses!
Given different queries, keep track of the amount of money paid to the different employees in bonuses. Queries will be one of four types:
Employees are numbered starting at 1 (the CEO) and all new employees are given the next integer employee identification (ID) number in the order they were hired into the pizzeria. The company initially has the CEO as the sole employee.
The input will begin with a line containing two integers, $$$N$$$ ($$$1 \leq N \leq 10^5$$$) and $$$S$$$ ($$$0 \leq S \leq 10^6$$$) representing the number of queries and the starting bonus multiplier for all new employees (including Louie). The next $$$N$$$ lines describe the queries using one of the following four formats:
For each query of the fourth kind, print out a single integer representing the amount of money paid in bonuses to the specific employee so far.
7 1 3 1 10 4 1 2 1 2 1 1 3 1 5 4 1 4 2
10 20 5
13 10 1 1 1 1 2 2 20 3 1 5 4 1 4 2 4 3 1 2 3 2 7 4 1 4 2 4 3 4 4
50 100 50 50 240 50 70
| Название |
|---|


