結果
問題 |
No.1523 +/- Tree
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:35:58 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 932 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 81,924 KB |
実行使用メモリ | 71,100 KB |
最終ジャッジ日時 | 2025-06-12 18:36:14 |
合計ジャッジ時間 | 7,619 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 29 |
ソースコード
n, k = map(int, input().split()) if k == 1 or k == n - 1: print("No") else: print("Yes") edges = [] # Construct a chain with a negative edge in the middle # Middle edge is at position k, with value -(k+1) # Other edges are 1 # This works for the sample case and similar configurations for i in range(1, n): if i == k: edges.append((i, i+1, -(k + 1))) else: edges.append((i, i+1, 1)) # Check if the total sum is positive total = sum(w for u, v, w in edges) if total <= 0: # Adjust the first and last edges to ensure total sum is positive # For example, set them to 2 instead of 1 edges = [] for i in range(1, n): if i == k: edges.append((i, i+1, -(k + 1))) else: edges.append((i, i+1, 2)) # Output the edges for u, v, w in edges: print(u, v, w)