結果
問題 |
No.1523 +/- Tree
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:27:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 326 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 61,660 KB |
最終ジャッジ日時 | 2025-06-12 13:33:14 |
合計ジャッジ時間 | 6,543 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 28 |
ソースコード
n, k = map(int, input().split()) if k == 1 or k == n-1: print("No") else: if k == 2: edges = [] current = 1 for i in range(n-1): if i % 2 == 0: edges.append((current, current+1, 2)) else: edges.append((current, current+1, -3)) current += 1 total = sum(w for u, v, w in edges) if total > 0: print("Yes") for u, v, w in edges: print(u, v, w) else: print("No") elif k == 3: edges = [] current = 1 for i in range(n-1): if i % 3 == 0: edges.append((current, current+1, 3)) else: edges.append((current, current+1, -2)) current += 1 total = sum(w for u, v, w in edges) if total > 0: print("Yes") for u, v, w in edges: print(u, v, w) else: print("No") else: print("No")