Bride of Pipe Stream

시간 제한12초메모리 제한2048 MB

요약
각 정거장이 배출관으로 보내는 양을 정해, 고정 비율로 분배되는 관을 거쳐 모든 저수지가 받는 최소 유량을 최대화한다.
난이도

어려움10점 중 8점

유형
이분 탐색, 그래프, 그리디, 수학
정답자
아직 제출이 없습니다

문제

The story continues! For several years now, your town has been gifted with an abundance of Flubber, the adorable-but-slightly-flammable-and-toxic-and-acidic-and-sentient-and-mischievous man-made chemical. The search continues for more (or, well, any) uses for the substance. But in the meantime, the Flubber factory continues to produce it at full capacity. Efforts to shut it down have failed, partly because nobody is sure who is actually running the factory.

You’ve been tasked with storing the perpetually-flowing Flubber in various Flubber reservoirs for future use (or, at least, to get it out of everyone’s hair – literally). To accomplish this, you have access to a complicated network of Flubber ducts, connecting up various Flubber stations and reservoirs.

Every Flubber station has one or more Flubber ducts leading from it, and has various gates that may be raised or lowered so that incoming Flubber will drain into the output Flubber ducts in any desired proportion. For instance, you can send all the Flubber down one duct, or split it between two ducts 2525–7575, etc.

In contrast, a Flubber duct flows down to one or more lower stations or reservoirs, but the Flubber drains into them in a fixed proportion that you do not control. It is possible that some of the Flubber is lost to the environment as well, but that is a problem for your successor, not you.

You would like to fill all the reservoirs as quickly as possible. That is, you want to maximize the minimum amount of Flubber flowing into any of the reservoirs, among all possible configurations of station drainage.

Figure C.1 illustrates the two sample inputs. Stations and reservoirs are shown as numbered nodes, colored green for stations and blue for reservoirs. Ducts are depicted as white nodes. For example, in the first sample input (left), Flubber can be sent from station 11 in any proportion to its two downstream ducts, but each duct will distribute its inflow according to the percentages printed on its outgoing edges.

Figure C.1: Illustrations of the two sample inputs.

입력

The first line of input contains three integers ss, rr, and dd, where ss (1≤s≤10,0001 ≤ s ≤ 10\\, 000) is the number of stations, rr (1≤r≤31 ≤ r ≤ 3) is the number of reservoirs, and dd (s≤d≤20,000s ≤ d ≤ 20\\, 000) is the number of ducts. The stations are numbered from 11 to ss and the reservoirs are numbered from s+1s + 1 to s+rs + r, in decreasing order of altitude. The factory’s Flubber initially flows into station 11.

Each of the remaining dd lines starts with two integers ii and nn, where ii (1≤i≤s1 ≤ i ≤ s) is the station that can drain into this duct, and nn (1≤n≤101 ≤ n ≤ 10) is the number of outputs of this duct. The remainder of the line contains nn pairs of integers oo and pp, where oo (i<o≤s+ri < o ≤ s + r) is a station or reservoir to which this duct drains, and pp (1≤p≤1001 ≤ p ≤ 100) is the percentage of the Flubber entering the duct that will drain to oo. The oo values for a given duct are distinct. Every station has at least one duct that it can drain into. The percentages for a given duct’s outputs will sum to at most 100100.

출력

Output a single percentage ff, which is the highest possible percentage such that, for some configuration of station drainage, all reservoirs receive at least ff% of the factory’s produced Flubber. Your answer should have an absolute error of at most 10−610^{−6}.

예제2

  1. 예제 1

    입력
    2 3 3
    1 2 3 80 4 10
    1 2 2 40 4 30
    2 1 5 100
    
    예상 출력
    24.0
    
  2. 예제 2

    입력
    1 2 3
    1 1 2 50
    1 1 3 50
    1 2 2 40 3 60
    
    예상 출력
    42.8571428571