結果

問題 No.2493 K-th in L2 with L1
ユーザー 👑 KA37RIKA37RI
提出日時 2023-10-06 21:46:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2023-10-06 21:46:56
合計ジャッジ時間 844 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
9,972 KB
testcase_01 AC 29 ms
9,972 KB
testcase_02 AC 29 ms
10,016 KB
testcase_03 AC 28 ms
9,904 KB
testcase_04 AC 27 ms
9,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(d, k):
	if k == 1 or k <= 4 * d:
		print("Yes")
		print(*points[d][k-1])
	else:
		print("No")
		
points = [None for _ in range(101)]
points[0] = [(0, 0)]
for d in range(1, 101):
	points[d] = [(0, d), (0, -d), (d, 0), (-d, 0)]
	for x in range(1, d):
		points[d].append((x, d - x))
		points[d].append((x, -d + x))
		points[d].append((-x, d - x))
		points[d].append((-x, -d + x))
	points[d].sort(key=lambda a: a[0] * a[0] + a[1] * a[1])

q = int(input())
for _ in range(q):
	di, ki = [int(x) for x in input().split()]
	solve(di, ki)
0