시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 1 | 1 | 1 | 100.000% |
The Unsweet Cupcake Factory (UCF) has recently seen a sudden increase in sales and business has been booming. Thus, the company has been rapidly expanding and is hiring new people nearly every day. Furthermore, to increase company morale (because the sugarless cupcakes don’t seem to be helping), UCF has been paying out bonuses to employees belonging to certain departments according to each individual’s performance.
The company is structured as follows:
When UCF decides that a certain department is doing well, it 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 with the same bonus multiplier, but depending on performance, an employee’s bonus multiplier can change thus potentially changing the amount of money that employee gets for future bonuses.
UCF has found it to be quite a nuisance to handle the sudden increase in staff size. Thus, they have enlisted 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 company. Initially, the company has only the CEO, i.e., only one employee.
The input will begin with a line containing two integers, n and S (1 ≤ n ≤ 105; 0 ≤ S ≤ 106), representing (respectively) the number of queries to follow and the starting bonus multiplier for all new hires (including the CEO). The next n lines describe the queries and each is in one of the following four formats:
Assume that all the input values are valid, e.g., when referring to a supervisor (or an employee), assume that the supervisor (or the employee) exists.
Note that there will not be a query of Type-1 to indicate the hiring of CEO, i.e., assume the company starts with one employee (CEO).
For each Type-4 query, print out a single line containing an integer representing the amount of money paid in bonuses to the employee in question thus 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