Universal Cup Judging System

Universal Cup

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Interactivo
Estadísticas

有 $n$ 隻青蛙,編號為 $1$ 到 $n$,每隻青蛙初始時皆位於笛卡兒平面上的一個整數格點。某個外部干擾突然刺激了其中一隻青蛙,引發了一場連鎖反應,青蛙們會依照以下規則行動。

當青蛙 $i$($1 \le i \le n$)受到刺激時,牠可以選擇以下兩種行動之一:

  • 跳向另一隻青蛙 $j$($1 \le j \le n$,$j \ne i$),並瞬間落在其當前位置相對於青蛙 $j$ 當前所在點的對稱點上(若在跳躍前青蛙 $i$ 與青蛙 $j$ 重合,則牠會落在該重合點上);在這次跳躍結束後,青蛙 $j$ 會立即成為下一隻且唯一一隻受到刺激的青蛙;
  • 或者留在原地,在此情況下所有跳躍結束,不再有任何青蛙處於受刺激狀態。

一隻青蛙可能會在不同時刻受到多次刺激,而有些青蛙則可能從未受到刺激。

你觀察到第一隻受到刺激的青蛙編號為 $s$,但由於跳躍次數過多,你無法捕捉整個過程。幸運的是,你認得每一隻青蛙,因此你記錄了牠們的初始位置 $P_1, P_2, \ldots, P_n$ 以及所有跳躍結束後的最終位置 $Q_1, Q_2, \ldots, Q_n$。同時你也注意到,所有初始位置皆兩兩相異,且所有最終位置亦兩兩相異。

令 $t$ 為最後一隻受到刺激的青蛙編號,亦即在受到刺激時選擇留在原地、且其後不再發生任何跳躍的那隻青蛙。請找出 $t$。

輸入格式

第一行包含兩個整數 $n$($2 \le n \le 10^5$)與 $s$($1 \le s \le n$),分別代表青蛙的數量以及第一隻受到刺激的青蛙編號。

接下來 $n$ 行中的第 $i$ 行包含四個整數 $px_i$、$py_i$、$qx_i$ 與 $qy_i$($-10^9 \le px_i, py_i, qx_i, qy_i \le 10^9$),其中 $P_i = (px_i, py_i)$ 與 $Q_i = (qx_i, qy_i)$ 分別代表青蛙 $i$ 在平面上的初始位置與最終位置。

保證所有初始位置 $P_1, P_2, \ldots, P_n$ 兩兩相異。所有最終位置 $Q_1, Q_2, \ldots, Q_n$ 亦兩兩相異,且對應於某個遵循上述規則、長度至多為 $2 \times 10^5$ 的刺激序列。

輸出格式

輸出一個整數 $t$,代表最後一隻受到刺激的青蛙編號。

範例

3 1
6 3 2 3
4 3 2 1
3 4 1 6
1

說明

在範例中,對應的刺激序列為 $[1, 2, 3, 2, 1]$。

problem_14950_ec9d2d17a5773e676fc4faa8dfa3dd53.png

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.