結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,372 KB
testcase_01 AC 73 ms
71,216 KB
testcase_02 AC 78 ms
75,452 KB
testcase_03 AC 79 ms
75,488 KB
testcase_04 WA -
testcase_05 AC 86 ms
76,552 KB
testcase_06 WA -
testcase_07 AC 99 ms
76,792 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

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:
            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