#P13813. [CERC 2022] Money Laundering

    ID: 15619 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2022Special JudgeTarjan高斯消元ICPCCERC

[CERC 2022] Money Laundering

题目描述

Consider a company AA that made a 100100 \, \text{€} of profit this year. The company's owners are Ivan with 52.8%52.8\% ownership share and Robi with a 47.2%47.2\% ownership share. Naturally, the profits are shared proportionally to the shares with Ivan receiving 52.852.8 \, \text{€} and Robi 47.247.2 \, \text{€}.

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 BB and change the ownership shares. Ivan now only owns 1%1\% of company AA, Robi only 2%2\%, the company BB owns a 49%49\% share of AA and AA owns 48%48\% of itself. Company BB has a similar ownership structure: 70%70\% ownership share belongs to BB itself, 25%25\% to AA, 3%3\% to Ivan and 2%2\% 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 BB.

Ultimate ownership shares can be determined as follows: let the company AA have 100100 \, \text{€} of profit and BB have 00 \, \text{€}. The profits are paid out to all direct owners in proportion to their ownership share. However, since AA and BB 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 AA and BB receive are paid out again, with Ivan and Robi getting a share, as well as AA and BB. 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 AA.

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 PP and QQ belong to different sectors, it cannot happen that

  • PP would own a (potentially indirect) share of QQ and
  • QQ would own a (potentially indirect) share of PP.

One or none of these statements could be true, but not both.

输入格式

The first line contains two space-separated integers cc and pp, representing the number of companies and number of persons, respectively. Then cc lines follow, and ii-th of them contains the description of ii-th company. The line contains an integer kik_i, the number of owners, and then kik_i entries of the form oi,j:pi,jo_{i,j} : p_{i,j}, where oi,jo_{i,j} is the designation of the jj-th owner (person or company) and pi,jp_{i,j} 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 ii-th line should include shares of all persons in the ii-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 10410^{-4}.

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

  • 1c,p1031 \leq c, p \leq 10^3
  • 1i=1nki1041 \leq \sum_{i=1}^{n} k_i \leq 10^4
  • oi,jo_{i,j} can have two forms: Px\text{Px} or Cy\text{Cy}, indicating that the owner is the xx-th person or yy-th company, respectively. It is guaranteed that 1xp1 \leq x \leq p, and 1yc1 \leq y \leq c holds.
  • ki1k_i \geq 1
  • 0<pi,j1000 < p_{i,j} \leq 100
  • j=1kipi,j=100\sum_{j=1}^{k_i} p_{i,j} = 100
  • The identifiers {oi,j}j=1ki\{o_{i,j}\}_{j=1}^{k_i} 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 AA would own a 100%100\% of BB and BB a 100%100\% of AA is forbidden.