結果

問題 No.2493 K-th in L2 with L1
ユーザー pitPpitP
提出日時 2023-10-06 21:42:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 80,156 KB
最終ジャッジ日時 2024-07-26 15:54:12
合計ジャッジ時間 1,740 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

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