結果

問題 No.2493 K-th in L2 with L1
ユーザー pitPpitP
提出日時 2023-10-06 21:42:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 81,548 KB
最終ジャッジ日時 2023-10-06 21:42:09
合計ジャッジ時間 2,396 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
77,560 KB
testcase_01 AC 364 ms
81,512 KB
testcase_02 AC 408 ms
81,548 KB
testcase_03 AC 356 ms
81,100 KB
testcase_04 AC 102 ms
72,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cmp_to_key
Q = int(input())

for _ in range(Q):
    D, K = map(int,input().split())
    points = []
    for i in range(-D, D + 1):
        points.append([i, D - abs(i)])
        if abs(i) != D : points.append([i, -(D - abs(i))])
    
    if len(points) < K :
        print("No")
    else:
        print("Yes")
        def cmp(a, b):
            if (a[0] ** 2 + a[1] ** 2) < (b[0] ** 2 + b[1] ** 2) :
                return -1
            else:
                return 1
        
        points.sort(key=cmp_to_key(cmp))
        print(*points[K - 1])
0