#P13813. [CERC 2022] Money Laundering
[CERC 2022] Money Laundering
题目描述
Consider a company that made a of profit this year. The company's owners are Ivan with ownership share and Robi with a ownership share. Naturally, the profits are shared proportionally to the shares with Ivan receiving and Robi .
They will have to pay tax on the received profits, but would like to avoid doing so, if at all possible. Sadly, the ownership structure of their company is too simple and it's easily discoverable how much profits each of them received.
For the next year, they prepare a plan. They make a shell company and change the ownership shares. Ivan now only owns of company , Robi only , the company owns a share of and owns of itself. Company has a similar ownership structure: ownership share belongs to itself, to , to Ivan and to Robi.
Looking naively, Ivan and Robi have very small ownership shares. However, we are interested in the ownership shares of ultimate beneficial owners, the persons who will ultimately profit, which are Ivan and Robi in our case. We wish to determine their ultimate ownership shares, which turn out to be approximately equal to what they were before the introduction of .
Ultimate ownership shares can be determined as follows: let the company have of profit and have . The profits are paid out to all direct owners in proportion to their ownership share. However, since and are partial owners of themselves, they receive a part of the profit. To determine the ultimate share of the ultimate beneficial owners, we repeat the procedure – any profits that and receive are paid out again, with Ivan and Robi getting a share, as well as and . This is repeated ad infinitum until (theoretically, after an infinite number of steps) all money is paid out to the ultimate beneficial owners, and the ratio of the final sums received by Ivan and Robi is by definition equal to their ultimate share of .
For a given structure of companies, determine the shares of the ultimate beneficial owners. However, the companies do not form a random network of ownership, but are structured in industrial sectors. Companies within sectors may form arbitrary ownership structures, but this is not true for companies in different sectors. If companies and belong to different sectors, it cannot happen that
- would own a (potentially indirect) share of and
- would own a (potentially indirect) share of .
One or none of these statements could be true, but not both.
输入格式
The first line contains two space-separated integers and , representing the number of companies and number of persons, respectively. Then lines follow, and -th of them contains the description of -th company. The line contains an integer , the number of owners, and then entries of the form , where is the designation of the -th owner (person or company) and is their share in percentages. The share will have exactly one decimal place.
输出格式
Output the ultimate ownership shares of all persons in all companies. The -th line should include shares of all persons in the -th company, including persons with no share. The share is between 0 and 1. Shares in a line should be separated by a space. The answer will be considered correct if its absolute or relative error is less than .
2 2
2 P1:50.1 P2:49.9
2 P1:23.4 P2:76.6
0.501000 0.499000
0.234000 0.766000
2 2
2 P1:50.0 P2:50.0
3 P1:20.0 P2:30.0 C1:50.0
0.500000 0.500000
0.450000 0.550000
2 2
4 P1:1.0 P2:2.0 C2:49.0 C1:48.0
4 C2:70.0 C1:25.0 P1:3.0 P2:2.0
0.528358 0.471642
0.540299 0.459701
3 2
5 P1:1.0 P2:2.0 C2:49.0 C1:38.0 C3:10.0
4 C2:70.0 C1:25.0 P1:3.0 P2:2.0
2 P1:20.0 P2:80.0
0.373228 0.626772
0.411024 0.588976
0.2 0.8
提示
Input limits
- can have two forms: or , indicating that the owner is the -th person or -th company, respectively. It is guaranteed that , and holds.
- The identifiers are unique, i.e. each owner is listed at most once.
- The number of companies belonging to each sector is less than 10.
- Each company has at least one ultimate beneficial owner. For example, a scheme where would own a of and a of is forbidden.