結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー tamatotamato
提出日時 2021-08-06 08:56:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,660 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 87,468 KB
実行使用メモリ 77,180 KB
最終ジャッジ日時 2023-10-15 04:03:33
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,424 KB
testcase_01 WA -
testcase_02 AC 79 ms
75,596 KB
testcase_03 AC 80 ms
75,816 KB
testcase_04 AC 92 ms
76,388 KB
testcase_05 AC 87 ms
76,724 KB
testcase_06 AC 101 ms
77,068 KB
testcase_07 AC 91 ms
76,732 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N, T = map(int, input().split())
        if T % 2 == 0:
            print("Yes")
            for i in range(1, N+1):
                for j in range(i+1, N+1):
                    if i == 1:
                        print(i, j, T // 2)
                    else:
                        print(i, j, 0)
        else:
            if N <= 3:
                print("Yes")
                for i in range(1, N+1):
                    for j in range(i+1, N+1):
                        if i == 1 and j == 2:
                            print(i, j, T)
                        else:
                            print(i, j, 0)
            elif N & 1:
                if T >= N:
                    T -= N
                    print("Yes")
                    for i in range(1, N + 1):
                        for j in range(i + 1, N + 1):
                            if i == 1:
                                print(i, j, T // 2 + 1)
                            else:
                                print(i, j, 1)
                else:
                    if T == N - 2:
                        print("Yes")
                        for i in range(1, N+1):
                            for j in range(i+1, N+1):
                                if i == 1:
                                    print(i, j, 0)
                                else:
                                    print(i, j, 1)
                    else:
                        print("No")
            else:
                print("No")


if __name__ == '__main__':
    main()
0