QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#17777. 星図の再描画

Statistiques

画板上共有 $n$ 個の星があり、これらを二次元平面上の点とみなすことができます。第 $i$ 番目 ($1 \le i \le n$) の星の座標は $(x_i, y_i)$ です。すべての星の $x$ 座標は互いに異なり、すべての $y$ 座標も互いに異なることが保証されます。

星座を描くたびに、これら $n$ 個の星から 3 個を選び、それらを互いに結んで三角形を構成する必要があります。平衡の美しさを表現するため、この三角形は特定の境界条件を満たす必要があります。すなわち、4 辺がすべて座標軸に平行な長方形が存在し、その三角形の 3 つの頂点がすべてその長方形の境界上に位置していなければなりません。同時に、星図の構造を明確に保つため、描かれたすべての三角形の内部領域(頂点と境界を含まない)は、互いに交差してはなりません。

最大でいくつの星座を描くことができるかを計算し、具体的な描画方案を一つ出力してください。

各テストケースには複数のテストデータが含まれます。入力の最初の行には正整数 $T$ ($1 \le T \le 2 \times 10^4$) が含まれ、データセットの数を示します。各テストデータについて:

  • 最初の行には正整数 $n$ ($3 \le n \le 2 \times 10^5$) が含まれ、星の数を示します。
  • 続く $n$ 行の各行には、2 つの整数 $x_i, y_i$ ($|x_i|, |y_i| \le 10^9$) が含まれ、第 $i$ 番目の星の座標を示します。すべての $x_i$ は互いに異なり、すべての $y_i$ も互いに異なることが保証されます。

すべてのテストデータにおける $n$ の合計は $2 \times 10^5$ を超えないことが保証されます。

各テストデータについて:

  • 最初の行に、描画可能な星座の最大数 $m$ を出力します。
  • 続く $m$ 行の各行に、3 つの異なる正整数 $x, y, z$ ($1 \le x, y, z \le n$) を出力し、一つの星座を構成する 3 つの星のインデックスを示します。

入出力例

入力 1

2
8
-10 1
-2 6
5 10
8 -9
-1 -2
3 0
0 3
1 -8
8
8 8
-5 3
-4 1
5 7
10 10
-3 5
-8 -10
-7 -1

出力 1

8
6 5 8
6 8 4
1 6 5
7 1 6
2 7 1
3 2 7
3 7 6
3 6 4
2
2 3 8
6 2 3

注記

第一組のテストデータについて、サンプル出力で描画された星図は以下の通りです。

第二組のテストデータについて、サンプル出力で描画された星図は以下の通りです。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1608EditorialOpenNew Editorial for Problem #17777Anonymous2026-05-29 19:29:54View
#1598EditorialOpenOfficial EditorialAnonymous2026-04-28 21:49:17View

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.