CF925F.Parametric Circulation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vova has recently learned what a circulaton in a graph is. Recall the definition: let G=(V,E)G = (V, E) be a directed graph. A circulation ff is such a collection of non-negative real numbers fef_e ( eEe \in E ), that for each vertex vVv \in V the following conservation condition holds:

$$\sum\limits_{e \in \delta^{-}(v)} f_e = \sum\limits_{e \in \delta^{+}(v)} f_e $$ </p><p>where $\\delta^{+}(v)$ is the set of edges that end in the vertex $v$ , and $\\delta^{-}(v)$ is the set of edges that start in the vertex $v$ . In other words, for each vertex the total incoming flow should be equal to the total outcoming flow.</p><p>Let a $lr$ -circulation be such a circulation $f$ that for each edge the condition $l\_e \\leq f\_e \\leq r\_e$ holds, where $l\_e$ and $r\_e$ for each edge $e \\in E$ are two non-negative real numbers denoting the lower and upper bounds on the value of the circulation on this edge $e$ .</p><p>Vova can't stop thinking about applications of a new topic. Right now he thinks about the following <span class="tex-font-style-it">natural</span> question: let the graph be fixed, and each value $l\_e$ and $r\_e$ be a linear function of a real variable $t$ :</p><p> $$ l_e(t) = a_e t + b_e $$ $$ r_e(t) = c_e t + d_e $$ </p><p>Note that $t$ is the <span class="tex-font-style-bf">same</span> for all edges.</p><p>Let $t$ be chosen at random from uniform distribution on a segment $\[0, 1\]$ . What is the probability of existence of $lr$$$-circulation in the graph?

输入格式

The first line contains two integers nn , mm ( 1n10001 \leq n \leq 1000 , 1m20001 \leq m \leq 2000 ).

Each of the next mm lines describes edges of the graph in the format ueu_e , vev_e , aea_e , beb_e , cec_e , ded_e ( 1ue,ven1 \leq u_e, v_e \leq n , 104ae,ce104-10^4 \leq a_e, c_e \leq 10^4 , 0be,de1040 \leq b_e, d_e \leq 10^4 ), where ueu_e and vev_e are the startpoint and the endpoint of the edge ee , and the remaining 4 integers describe the linear functions for the upper and lower bound of circulation.

It is guaranteed that for any t[0,1]t \in [0, 1] and for any edge eEe \in E the following condition holds 0le(t)re(t)1040 \leq l_e(t) \leq r_e(t) \leq 10^4 .

输出格式

Print a single real integer — the probability of existence of lrlr -circulation in the graph, given that tt is chosen uniformly at random from the segment [0,1][0, 1] . Your answer is considered correct if its absolute difference from jury's answer is not greater than 10610^{-6} .

输入输出样例

  • 输入#1

    3 3
    1 2 0 3 -4 7
    2 3 -2 5 1 6
    3 1 0 4 0 4
    

    输出#1

    0.25

说明/提示

In the first example the conservation condition allows only circulations with equal values fef_e for all three edges. The value of circulation on the last edge should be 44 whatever tt is chosen, so the probability is

$$P(4 \in [3, -4t + 7]~~\&~~4 \in [-2t + 5, t + 6]) = 0.25 $$
首页