結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,060 KB
testcase_01 AC 76 ms
71,532 KB
testcase_02 AC 78 ms
75,376 KB
testcase_03 AC 78 ms
75,332 KB
testcase_04 WA -
testcase_05 AC 87 ms
76,488 KB
testcase_06 WA -
testcase_07 AC 100 ms
76,668 KB
testcase_08 WA -
testcase_09 AC 96 ms
76,456 KB
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:
            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 = T - N
            if rem % 2 == 1:
                print ("No")
            else:
                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