結果

問題 No.2493 K-th in L2 with L1
ユーザー 👑 rin204rin204
提出日時 2023-10-06 21:25:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 76,052 KB
最終ジャッジ日時 2023-10-06 21:25:50
合計ジャッジ時間 1,374 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,576 KB
testcase_01 AC 83 ms
76,012 KB
testcase_02 AC 83 ms
76,008 KB
testcase_03 AC 82 ms
76,052 KB
testcase_04 AC 70 ms
71,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, k = map(int, input().split())
    lst = []
    for i in range(n + 1):
        j = n - i
        lst.append((i, j))
        if j != 0:
            lst.append((i, -j))
        if i != 0:
            lst.append((-i, -j))
            if j != 0:
                lst.append((-i, -j))
    if k > len(lst):
        print("No")
        return
    lst.sort(key=lambda x: x[0] * x[0] + x[1] * x[1])
    print("Yes")
    print(*lst[k - 1])


for _ in range(int(input())):
    solve()
0