結果

問題 No.1523 +/- Tree
ユーザー nrktnrkt
提出日時 2021-05-31 21:49:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,482 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 73,820 KB
最終ジャッジ日時 2024-04-26 09:37:52
合計ジャッジ時間 4,659 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,532 KB
testcase_01 AC 39 ms
55,668 KB
testcase_02 AC 39 ms
54,576 KB
testcase_03 AC 40 ms
55,384 KB
testcase_04 AC 42 ms
55,132 KB
testcase_05 AC 40 ms
56,452 KB
testcase_06 AC 41 ms
55,564 KB
testcase_07 AC 43 ms
55,828 KB
testcase_08 AC 40 ms
55,448 KB
testcase_09 AC 40 ms
54,948 KB
testcase_10 AC 40 ms
55,048 KB
testcase_11 AC 41 ms
56,088 KB
testcase_12 AC 68 ms
72,968 KB
testcase_13 AC 71 ms
73,820 KB
testcase_14 AC 65 ms
70,816 KB
testcase_15 AC 48 ms
63,944 KB
testcase_16 AC 62 ms
70,772 KB
testcase_17 AC 39 ms
55,076 KB
testcase_18 AC 71 ms
73,376 KB
testcase_19 AC 42 ms
55,220 KB
testcase_20 AC 39 ms
56,132 KB
testcase_21 AC 42 ms
54,596 KB
testcase_22 AC 41 ms
55,552 KB
testcase_23 AC 40 ms
55,536 KB
testcase_24 AC 41 ms
54,680 KB
testcase_25 AC 60 ms
69,904 KB
testcase_26 AC 57 ms
66,484 KB
testcase_27 AC 56 ms
70,448 KB
testcase_28 AC 57 ms
70,316 KB
testcase_29 AC 52 ms
64,408 KB
testcase_30 AC 53 ms
64,188 KB
testcase_31 AC 61 ms
69,320 KB
testcase_32 AC 43 ms
55,016 KB
testcase_33 AC 61 ms
70,396 KB
testcase_34 AC 58 ms
66,344 KB
testcase_35 AC 57 ms
70,200 KB
testcase_36 AC 54 ms
65,556 KB
testcase_37 AC 54 ms
66,640 KB
testcase_38 AC 46 ms
61,196 KB
testcase_39 AC 52 ms
68,120 KB
testcase_40 AC 63 ms
72,784 KB
testcase_41 AC 55 ms
69,460 KB
testcase_42 AC 40 ms
55,016 KB
testcase_43 AC 56 ms
69,964 KB
testcase_44 AC 60 ms
71,204 KB
testcase_45 AC 41 ms
55,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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)
        
0