結果

問題 No.2493 K-th in L2 with L1
ユーザー sasa8uyauyasasa8uyauya
提出日時 2023-10-06 21:41:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 76,688 KB
最終ジャッジ日時 2023-10-06 21:41:32
合計ジャッジ時間 1,404 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,868 KB
testcase_01 AC 103 ms
76,316 KB
testcase_02 AC 104 ms
76,288 KB
testcase_03 AC 106 ms
76,688 KB
testcase_04 AC 73 ms
71,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
  d,k=map(int,input().split())
  if d==0:
    if k==1:
      print("Yes")
      print(0,0)
      continue
    else:
      print("No")
      continue
  p=[]
  for i in range(d):
    g=i**2+(d-i)**2
    p+=[(g,i,d-i)]
    p+=[(g,-i,-d+i)]
    p+=[(g,d-i,-i)]
    p+=[(g,-d+i,i)]
  p.sort()
  l=0
  r=0
  f=0
  while l<len(p):
    while r+1<len(p) and p[r+1][0]==p[l][0]:
      r+=1
    if l<k and r+1>=k and f==0:
      f=1
      print("Yes")
      print(*p[l][1:])
    l=r+1
    r=l
  if f==0:
    print("No")
0