結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-06-27 16:08:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 76,988 KB
最終ジャッジ日時 2023-09-07 18:01:21
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,444 KB
testcase_01 AC 75 ms
71,388 KB
testcase_02 AC 79 ms
75,516 KB
testcase_03 AC 80 ms
75,268 KB
testcase_04 WA -
testcase_05 AC 89 ms
76,428 KB
testcase_06 WA -
testcase_07 AC 99 ms
76,924 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1571

"""

from sys import stdin
import sys

Q = int(stdin.readline())

for loop in range(Q):

    N,T = map(int,stdin.readline().split())

    if T % 2 == 0:
        ans = []
        
        for b in range(1,N+1):
            for a in range(1,b):

                if a == 1 or b == 1:
                    ans.append((a,b,T//2))
                else:
                    ans.append((a,b,0))

        print ("Yes")
        for i in ans:
            print (*i)

    else:
        if N % 2 == 0 or N == 2:
            print ("No")
        elif N == 3:
            ans = [(1,2,T),(2,3,0),(1,3,0)]
            print ("Yes")
            for i in ans:
                print (*i)

        elif T >= N:
            ans = []
            rem = N - T
            for b in range(1,N+1):
                for a in range(1,b):

                    if a == 1 or b == 1:
                        ans.append((a,b,rem//2 + 1))
                    else:
                        ans.append((a,b,1))

            print ("Yes")
            for i in ans:
                print (*i)
        else:
            print ("No")
0