結果
| 問題 |
No.2967 Nana's Plus Permutation Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-16 16:57:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,905 bytes |
| コンパイル時間 | 612 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 95,208 KB |
| 平均クエリ数 | 4169.09 |
| 最終ジャッジ日時 | 2024-11-16 16:58:47 |
| 合計ジャッジ時間 | 35,634 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 3 WA * 62 |
ソースコード
"""input"""
#int-input
# input = sys.stdin.readline
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
#str-input
def SI(): return input()
def MSI(): return input().split()
def SI_L(): return list(SI())
def SI_LI(): return list(map(int, SI()))
#multiple-input
def LLI(n): return [LI() for _ in range(n)]
def LSI(n): return [SI() for _ in range(n)]
#1-indexを0-indexでinput
def MI_1(): return map(lambda x:int(x)-1, input().split())
def TI_1(): return tuple(MI_1())
def LI_1(): return list(MI_1())
from collections import deque,defaultdict,Counter
mod = 998244353
class fenwick_tree():
n=1
data=[0 for i in range(n)]
def __init__(self,N):
self.n=N
self.data=[0 for i in range(N)]
def add(self,p,x):
assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n)
p+=1
while(p<=self.n):
self.data[p-1]+=x
p+=p& -p
def sum(self,l,r):
assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n)
return self.sum0(r)-self.sum0(l)
def sum0(self,r):
s=0
while(r>0):
s+=self.data[r-1]
r-=r&-r
return s
#必ず入っている集合を見つける
#必ず以下マン、以上マンを見つける
# 上72回まで
# その後は8回
n = II()
p = [0]*(n+1)
cnt = [0]*(n+10)
#次どこに向かうかを示しておく
for i in range(1,n+1):
print(1,i,i)
p[i] = II()
cnt[p[i]] += 1
ml = 0
for i in range(1,n+1):
if cnt[i] == 0:
now = i
res = [now]
while p[now] != -1:
now = p[now]
res.append(now)
l = len(res)
if ml <= l:
ml = l
one = res[:]
o = one[0]
ans = [one[0],one[1]]
for i in range(n-2):
print(1,o,ans[-1])
ans.append(II())
print(2,*ans)