PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BF0000046. Người đo hệ số chênh lệch (Double-Kill Meter)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Người đo hệ số chênh lệch (Double-Kill Meter)

Double-Kill Meter

Source: Luogu

Version: Phuoc Hung OJ Extended

Problem Statement

Every participant has a positive real score. Each pledge is 1 A B k or 2 A B k. Under relaxation T>0T>0, avoiding all pledge penalties requires pA≥(k−T)pBp_A\ge(k-T)p_B for type 1, and pB<(k+T)pAp_B<(k+T)p_A for type 2. Some scores are fixed. Find the largest TT for which every score assignment violates a pledge; print -1 if none exists.

Input

First line n,s,tn,s,t; then ss lines o,A,B,ko,A,B,k; then tt fixed scores C,xC,x.

Output

Print -1 or a real number with absolute error at most 10−410^{-4}.

Subtasks

  • Subtask 1 (20 points): 1≤n≤51\le n\le5, 1≤s≤21\le s\le2, 1≤t≤n1\le t\le n; o∈{1,2}o\in\{1,2\}; 1≤A,B,C≤n1\le A,B,C\le n; 1≤k≤101\le k\le10, 1≤x≤1091\le x\le10^9; fixed-score indices CC are distinct.
  • Subtask 2 (30 points): 1≤n≤2001\le n\le200, 1≤s≤5001\le s\le500, t=nt=n; o∈{1,2}o\in\{1,2\}; 1≤A,B,C≤n1\le A,B,C\le n; 1≤k≤101\le k\le10, 1≤x≤1091\le x\le10^9; fixed-score indices CC are distinct.
  • Subtask 3 (50 points): 1≤n,s≤10001\le n,s\le1000, 1≤t≤n1\le t\le n; o∈{1,2}o\in\{1,2\}; 1≤A,B,C≤n1\le A,B,C\le n; 1≤k≤101\le k\le10, 1≤x≤1091\le x\le10^9; fixed-score indices CC are distinct.

Examples

Input

2 2 2
1 1 2 2
1 2 1 2
1 1
2 1

Output

1.0000000

Explanation

Both known scores are 11. Avoiding either type-1 penalty requires 1≥(2−T)⋅11\ge(2-T)\cdot1, equivalently T≥1T\ge1. For every 0<T<10<T<1 a penalty is unavoidable; for T≥1T\ge1 all pledges can hold. The threshold is 11.