QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 512 MB Total points: 100

#4474. 田野

Statistics

尋晚我見到你喺度奔跑

喺恩典廣闊嘅田野上

你唔再破碎,亦唔再痛苦。¹

你搵到咗一片一望無際嘅大田野,喺呢片田野入面,你忘記咗曾經破碎、痛苦嘅過去。你好似細路仔咁喺上帝嘅恩賜中奔跑。

不過,你發現咗一個問題:呢片田野入面有若干條峽谷,你隨時都有跌落峽谷嘅危險。為咗繼續自由自在噉奔跑,你決定用若干圍欄將呢啲峽谷圍住。

我哋可以忽略峽谷嘅闊度,將每條峽谷視為一條線段。呢啲線段可以相交,而你嘅圍欄必須係一條或多條封閉、唔自交,而且兩兩唔相交嘅曲線,令每條峽谷都完全喺某一條封閉曲線圍成嘅封閉區域之內。

當然,圍欄需要消耗資源,消耗嘅資源同圍欄嘅長度成正比。你希望將消耗嘅資源總量減到最少,所以你想求出圍欄總長度嘅下確界。換句話講,你想搵到最大嘅實數 $x$,令唔存在一個方案嘅圍欄總長度小於 $x$。

¹ 題面中嘅歌詞出自 Jackie Evancho 嘅 Open Fields of Grace,作曲者係 Lisa Venkatrathnam 同 Paul Sumares。

輸入格式

由檔案 fields.in 讀入資料。

輸入檔案第一行係一個整數 $n$,表示峽谷嘅數目。

之後 $n$ 行,第 $i$ 行有四個整數 $a_i,b_i,c_i,d_i$,表示第 $i$ 條峽谷係一條連接點 $(a_i,b_i)$ 同點 $(c_i,d_i)$ 嘅線段。保證兩個端點唔重合,唔同線段唔會涉及相同嘅點。保證任何三點都唔共線。

輸出格式

輸出到檔案 fields.out。

輸出一行一個實數,表示圍欄總長度嘅下確界。你嘅答案同標準答案之間,絕對誤差同相對誤差嘅較小值唔可以超過 $10^{-6}$。

樣例

輸入格式 1

1
0 0 0 1

輸出格式 1

2.00000000

說明

一個四個端點分別係 $(-0.01,-0.01),(-0.01,1.01),(0.01,1.01),(0.01,-0.01)$ 嘅長方形,完全包含輸入嘅線段,而且總長度係 $2.08$,略大於下確界。

我哋可以證明,唔存在長度啱啱好係 $2$ 嘅方案。我哋可以將正方形無限向輸入線段「收緊」,構造出長度係任何大於 $2$ 嘅值嘅方案。

輸入格式 2

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

輸出格式 2

23.563573998194637061425470524757

說明

下圖係輸入嘅線段,留意線段可以相交:

problem_4474_335f10b38b93a3cb6fc056191d311271.png

圖 1:樣例 2 說明

我哋可以無限「逼近」呢啲紅色曲線,構造出總長度係任何大於答案嘅值嘅方案。留意,根據樣例 1,我哋好容易知道左上角嘅紅色線段計咗兩次。

輸入格式 3

4
-1 1 -1 3
0 4 2 4
3 1 3 3
0 0 2 0

輸出格式 3

13.656854249492380195206754896839

說明

答案係 $8+4\sqrt{2}$。

說明如下圖:

problem_4474_c2809511898bfe9e3965bafe7003d019.png

圖 2:樣例 3 說明

我哋可以無限「逼近」呢啲紅色曲線,構造出總長度係任何大於 $8+4\sqrt{2}$ 嘅值嘅方案。

樣例 4

請睇選手目錄下面嘅 fields/fields4.in 同 fields/fields4.ans。

資料範圍

對於 $5\%$ 嘅資料,保證 $1\le n\le 1$。

對於 $10\%$ 嘅資料,保證 $1\le n\le 2$。

對於 $15\%$ 嘅資料,保證 $1\le n\le 10$。

對於 $30\%$ 嘅資料,保證 $1\le n\le 15$。

對於 $45\%$ 嘅資料,保證 $1\le n\le 30$。

對於 $55\%$ 嘅資料,保證 $1\le n\le 60$。

對於 $65\%$ 嘅資料,保證 $1\le n\le 120$。

對於 $75\%$ 嘅資料,保證 $1\le n\le 200$。

對於另外 $10\%$ 嘅資料,保證答案最多包含兩條曲線。

對於 $100\%$ 嘅資料,保證 $1\le n\le 250$,$0\le |a_i|,|b_i|,|c_i|,|d_i|\le 10^9$。保證兩個端點唔重合,唔同線段唔會涉及相同嘅點。保證任何三點都唔共線。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.