Universal Cup Judging System

Universal Cup

시간 제한: 1.0 s 메모리 제한: 1024 MB 총점: 100 인터랙티브
통계

有 $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.