Universal Cup Judging System

Universal Cup

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Interactif
Statistiques

這是一道互動題!

存在一個由 $N$ 個互不相同的正整數組成的隱藏陣列 $a_1, a_2, \dots, a_N$(其中 $N$ 為奇數);該陣列的一個錯誤副本儲存在另一個隱藏陣列 $b$ 中。陣列 $b$ 的每個元素定義如下:

  • $b_1 = a_2$
  • $b_N = a_{N-1}$
  • 對於每個滿足 $1 < i < N$ 的 $i$,$b_i = a_{i-1}$ 或 $b_i = a_{i+1}$(即相鄰元素之一)

你需要確定是否存在兩個下標 $i$ 和 $j$($i \neq j$,$1 \le i, j \le N$)使得 $b_i = b_j$。如果存在這樣的下標,請回傳它們;否則,指出不存在這樣的下標。

你可以透過以下操作查詢陣列 $a$ 和 $b$ 的元素:

  • 1 i:回傳 $a_i$ 的值($1 \le a_i \le 10^9$)
  • 2 i:回傳 $b_i$ 的值($1 \le b_i \le 10^9$)

你最多可以進行 20 次查詢。

互動協議

首先,你必須讀取一行,包含一個整數 $T$($1 \le T \le 100$),表示測試資料的數量。

接下來是 $T$ 組測試資料的互動過程。

對於每組測試資料,你必須首先讀取一行,包含一個整數 $N$($3 \le N \le 2\,001$,$N$ 為奇數)。

然後互動開始。你可以輸出一行,包含以下內容之一:

  • 1 x(詢問 $a_x$):然後,讀取一行,包含一個整數 $a_x$。
  • 2 x(詢問 $b_x$):然後,讀取一行,包含一個整數 $b_x$。
  • 3 i j(回答:兩個下標 $i, j$,滿足 $b_i = b_j$;如果不存在這樣的兩個下標,則輸出 -1 -1):然後,如果有下一組測試資料,則繼續進行;否則,程式終止。

在輸出每一行後,請不要忘記清空輸出緩衝區(flush)。例如:

  • C/C++ 中的 fflush(stdout);
  • Java 中的 System.out.flush();
  • Python 中的 sys.stdout.flush();
  • Pascal 中的 flush(output);
  • 其他語言請參閱相應文件。

範例

輸入 1

1
7
2
2

輸出 1

2 3
2 1
3 1 3

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.