結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー tamatotamato
提出日時 2021-08-06 09:03:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,838 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 87,428 KB
実行使用メモリ 77,204 KB
最終ジャッジ日時 2023-10-15 04:10:55
合計ジャッジ時間 2,469 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,844 KB
testcase_01 AC 77 ms
71,688 KB
testcase_02 AC 80 ms
75,484 KB
testcase_03 AC 79 ms
75,700 KB
testcase_04 AC 92 ms
77,080 KB
testcase_05 AC 87 ms
76,808 KB
testcase_06 AC 100 ms
77,204 KB
testcase_07 AC 94 ms
76,584 KB
testcase_08 AC 99 ms
77,132 KB
testcase_09 AC 98 ms
76,800 KB
testcase_10 AC 91 ms
76,756 KB
権限があれば一括ダウンロードができます

ソースコード

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 == 2:
                if T & 1:
                    print("No")
                else:
                    print("Yes")
                    print(1, 2, T // 2)
            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