結果
| 問題 |
No.1523 +/- Tree
|
| コンテスト | |
| ユーザー |
nrkt
|
| 提出日時 | 2021-05-31 21:49:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 1,482 bytes |
| コンパイル時間 | 468 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 72,576 KB |
| 最終ジャッジ日時 | 2024-11-08 23:58:19 |
| 合計ジャッジ時間 | 5,329 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 44 |
ソースコード
#!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
n, k = LI()
if k == 1 or k == n - 1:
print("No")
else:
if k == 2:
if (n - 1) % k == 0:
print("No")
else:
a = (n - 1) // k
b = a + 1
for x in range(2*n+1):
for y in range(x+1, 2*n+1):
if -a*y + b*x > 0:
break
else:
continue
break
print("Yes")
for i in range(1, n):
if i % k == 0:
print(i, i+1, -y)
elif i % k == 1:
print(i, i+1, x)
else:
print(i, i+1, 0)
else:
print("Yes")
for i in range(k-1):
if i == 0:
print(i+1, i+2, 2)
else:
print(i+1, i+2, 1)
print(k, k+1, -k-1)
for i in range(k+1, n):
print(k+1, i+1, 2)
nrkt