結果
| 問題 |
No.2967 Nana's Plus Permutation Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-16 22:23:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 676 ms / 2,000 ms |
| コード長 | 668 bytes |
| コンパイル時間 | 426 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 94,688 KB |
| 平均クエリ数 | 4170.09 |
| 最終ジャッジ日時 | 2024-11-16 22:23:36 |
| 合計ジャッジ時間 | 30,666 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 65 |
ソースコード
n = int(input())
to = [-1] * n
for i in range(n):
print(f"1 {i + 1} {i + 1}", flush=True)
j = int(input())
if j == -1:
to[i] = j
else:
to[i] = j - 1
dist = [-1] * n
def dfs(x):
if dist[x] != -1:
return dist[x]
if to[x] == -1:
dist[x] = 0
return 0
dist[x] = dfs(to[x]) + 1
return dist[x]
ma = -1
one = -1
for i in range(n):
dfs(i)
if ma < dist[i]:
ma = dist[i]
one = i
P = [0] * n
P[one] = 1
now = one
for i in range(2, n + 1):
print(f"1 {one + 1} {now + 1}", flush=True)
now = int(input()) - 1
P[now] = i
print(2, " ".join(map(str, P)), flush=True)