luogu#P4926. [1007] 倍杀测量者

    ID: 3938 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>二分Special Judge最短路差分约束洛谷月赛

[1007] 倍杀测量者

Problem Description

Today, Scarlet was lucky enough to witness a unique OI training session in the computer lab. Because of some strange SPJ, every contestant’s score in the contest was a positive real number (and it even has no upper limit).

When contestant A’s score is at least kk (k>0k>0) times contestant B’s score, we say contestant A kk-double-killed contestant B, and contestant B was kk-double-killed by contestant A.

Even more strangely (and more excitingly), before the training, many contestants made Flags such as “If I don’t kk-double-kill contestant X, I’ll eat something good,” or “If contestant Y kk-double-kills me, I’ll eat something good.”

Coach Patchouli, who knows the truth and still has a conscience, in order to keep order in the lab and avoid people eating too well and hurting their health, relaxed the Flag requirements. Patchouli set a positive constant TT. A contestant who made the Flag “If I don’t kk-double-kill contestant X, I’ll eat something good” will not need to eat something good as long as they successfully kTk-T-double-kill contestant X. Similarly, a contestant who made the Flag “If contestant Y kk-double-kills me, I’ll eat something good” will not need to eat something good as long as they are not successfully k+Tk+T-double-killed by contestant Y.

Scarlet, who already knows the scores of some contestants and the exact Flags, really cannot bear to see such a wonderful contest end with nobody eating something good. To make it easier to negotiate with Patchouli, Scarlet wants to determine the largest real number TT such that, after the contest, there will definitely be at least one contestant who has to fulfill their Flag and eat something good.

Input Format

The first line contains three integers n,s,tn,s,t, representing the number of contestants in the lab, the total number of Flags made by contestants, and the number of contestants’ scores known by Scarlet. The nn contestants are numbered from 11 to nn. The contestant with number kk is called contestant kk.

The next ss lines each contain four integers o,A,B,ko,A,B,k. Here, o=1o=1 means contestant A made the Flag “If I don’t kk-double-kill contestant B, I’ll eat something good,” and o=2o=2 means contestant A made the Flag “If contestant B kk-double-kills me, I’ll eat something good.”

The next tt lines each contain two integers C,xC,x, meaning Scarlet knows that contestant CC has score xx.

Output Format

If there exists a largest TT that can guarantee that, after the contest, there will be a contestant who eats something good, output TT. Your output is considered correct if the absolute error from the answer does not exceed 10410^{-4}.

If it does not exist, output -1.

3 5 1
1 2 1 2
1 3 2 2
1 3 1 4
2 1 2 2
2 1 3 4
1 1
-1
3 2 3
1 2 1 10
2 2 3 6
1 1
2 6
3 9
3.9999993984

Hint

  • For 30%30\% of the testdata, n5n\leq 5, s2s\leq 2.
  • For another 40%40\% of the testdata, it is guaranteed that t=nt=n.
  • For 100%100\% of the testdata, 1n,s10001\leq n,s\leq 1000, 1A,B,C,tn1\leq A,B,C,t\leq n, 1k101\leq k\leq 10, 1x1091\leq x\leq 10^9. It is guaranteed that all input CC are pairwise distinct.

Translated by ChatGPT 5