結果
| 問題 | No.3057 Tree Distance Set |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-04 09:56:49 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 569 bytes |
| 記録 | |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 95,852 KB |
| 実行使用メモリ | 83,840 KB |
| 最終ジャッジ日時 | 2026-08-04 09:57:38 |
| 合計ジャッジ時間 | 3,412 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 17 WA * 3 |
ソースコード
K = int(input())
D = sorted(list(map(int,input().split())))
if K==1:
print(2)
print(1,2,D[0])
print(2)
print(1,2)
elif K==2:
print(5)
print((1,2,(D[1]-D[0])//2))
print((2,3,D[0]//2))
print((2,4,D[0]//2))
print((1,5,D[1]//2))
print(3)
print(3,4,5)
else:
L = D[-1]
E = []
V = []
v = 2
for i in range(K-1):
d = D[i]
E += [(1,v,(L-d)//2),(v,v+1,d//2),(v,v+2,d//2)]
V += [v+1,v+2]
v += 3
print(v-1)
for u,v,w in E:
print(u,v,w)
print(len(V))
print(*V)