QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 128 MB 總分: 100 难度: [顯示]

#18225. 軌道交通

统计

三葉蟲非常喜歡建造地鐵。他設計了 $n$ 條路線,每條路線均有 $n+1$ 個站點選址,用平面上的座標表示。

為了豐富地鐵體驗,三葉蟲決定每條路線都是一條線段!也就是說,對於每條路線,三葉蟲僅會選擇兩個站點,在這兩個站點之間連一條線段。為了最大化乘客換乘的麻煩程度,三葉蟲要求建立的 $n$ 條地鐵之間兩兩交點個數最少。注意交點包含起點和終點站。請你規劃一種合法的方案。

人話:給定二維平面上 $n$ 種顏色的點各 $n+1$ 個。要求在每一種顏色中選出兩個不同的點連一條線段,且所有 $n$ 條線段兩兩交點個數最少。輸出構造方案。

注意:如果兩條線段共線,交點數定義為無窮大。所有無窮大認為相等。

輸入格式

本題有多組測試資料,第一行一個正整數 $T$ 表示資料組數,對於每一組測試資料:

第一行一個正整數 $n$ 表示路線的數量。

接下來 $n$ 行每行 $2n+2$ 個整數,其中第 $2i-1$ 個和第 $2i$ 個整數 $(x_i,y_i)$ 標識了當前路線一個站點的座標,且該站點的標號為 $i$。

保證所有的站點座標互不相同。

輸出格式

對於每一組測試資料,輸出 $n$ 行每行兩個正整數,依次表示每條路線連接的兩個站點的標號。你只需要輸出任意解。

範例

輸入格式 1

1
2
5 0 0 8 10 8
0 4 10 4 5 12

輸出格式 1

1 3
1 3

說明

圖中藍色和紅色的點分別表示一號線和二號線的站點,藍線和紅線分別表示一號線和二號線選擇的路線。

注意你只需要輸出任意解,即

1 2
2 3

也是正確答案。

資料範圍

子任務編號 分值 額外限制
1 30 $n\le 5,\sum n\le 50$
2 20 存在一種排列這 $n(n+1)$ 個點的方案使得第 $i$ 個點的座標恰為 $(i,i)$
3 20 $n\leq 100$
4 30

對於所有資料:$1\le n\le1000,\sum n\leq 2000$,$|x_i|,|y_i|\le10^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.