QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓

#5296. 平面圖

Estadísticas

在一個平面圖中有 $n$ 個頂點和 $m$ 條直線段,第 $i$ 個頂點的座標為 $(x_i, y_i)$,第 $j$ 條直線段連接頂點 $u_j$ 和頂點 $v_j$。權值為 $h_j$,除頂點 $u_j$ 和 $v_j$ 外直線段 $j$ 不經過其他的頂點。任意兩條直線段如果存在公共點,則該公共點一定是一個頂點,此時這兩條直線段都會連接這個頂點。對於任意的兩個頂點 $x$ 和 $y$,總是可以找到一頂點序列 $a_1, a_2, \dots, a_k$ 使得 $a_1 = x, a_k = y$ 且對於任意 $1 \leq i < k$ 滿足 $a_i$ 和 $a_{i + 1}$ 被一條直線段直接連接。

這 $m$ 條直線段將整個平面分成了若干個區域,其中只有一個區域是無窮大的,其餘均是有界的,我們稱無窮大的區域為禁區。

現在給出 $q$ 次詢問,每次給定平面中的任意兩個不是頂點且分別不在任意一條直線段上的點 $A$ 和 $B$,請畫一條曲線連接 $A$ 和 $B$,要求曲線不能經過禁區以及任何頂點,並使得穿過的直線段中權值最大的盡可能小。你需要對每次詢問回答這個值最小為多少。

輸入格式

第一行有兩個正整數 $n$、$m$,分別表示頂點數和直線段數。

接下來 $n$ 行,每行兩個整數,這部分中第 $i$ 行(總第 $i + 1$ 行)的兩個整數 $x_i, y_i$ 為頂點 $i$ 的座標。

接下來 $m$ 行,每行三個正整數 $u, v, h$,表示有一條直線段連接頂點 $u$ 和頂點 $v$,權值為 $h$。其中 $u \neq v$。

接下來的一行,有一個正整數 $q$,表示詢問數量。

接下來 $q$ 行,每行四個實數 $A_x, A_y, B_x, B_y$,表示一組兩個點座標分別為 $(A_x, A_y)$ 和 $(B_x, B_y)$ 的詢問。

輸出格式

輸出 $q$ 行,每行一個正整數,依次表示每個詢問的答案。特別的,若不需要跨過任何一條邊即可到達,請輸出 $0$;若不存在合法的曲線,請輸出 $-1$。

範例

輸入格式 1

9 12
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
1 2 10
2 3 10
3 6 10
6 9 10
9 8 10
8 7 10
7 4 10
4 1 10
2 5 3
5 8 2
5 6 4
4 5 1
3
1.5 1.5 2.5 2.5
1.5 2.5 2.5 1.5
0.5 0.5 1.5 1.5

輸出格式 1

2
3
-1

說明

(圖片暫無)

資料範圍

本題共設有 10 個測試點,每個測試點的規模與特徵如下:

測試點編號 $n, m, q$ 的範圍 $x, y$ 的範圍 其他特徵
1 $n = 10, m = 13, q = 20$ $0 \leq x \leq 1, 0 \leq y \leq 2000$ 所有直線段長度均等於 $1$
2 $n = 2012, m = 3016, q \leq 1000$ 所有直線段長度均等於 $1$
3 $n, m \leq 50, q \leq 200$ $0 \leq x, y \leq 1000$ 所有直線段長度均等於 $1$
4 $n, m \leq 100000, q \leq 100000$ 所有直線段長度均等於 $1$
5 所有直線段長度均等於 $1$
6 $n, m \leq 2000, q \leq 2000$ $0 \leq x, y \leq 10^7$ 每個有界區域都是凸多邊形且每條直線段的權值均等於 $1$
7 $n, m \leq 2000, q \leq 2000$ 每條直線段的權值均等於 $1$
8 $n, m \leq 100000, q \leq 100000$ $0 \leq x, y \leq 10^7$
9
10

對於全部資料,均滿足 $5 \leq n, m \leq 100000$,所有直線段的權值不會超過 $10^9$。所有詢問的座標均為不超過 $10^7$ 的非負實數,且保證是 $0.5$ 的奇數倍。

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.