結果

問題 No.2493 K-th in L2 with L1
ユーザー mattu34mattu34
提出日時 2023-10-07 16:19:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,842 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 78,532 KB
最終ジャッジ日時 2023-10-07 16:19:08
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
77,784 KB
testcase_01 AC 145 ms
78,484 KB
testcase_02 AC 142 ms
78,324 KB
testcase_03 AC 142 ms
78,532 KB
testcase_04 AC 90 ms
72,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import bisect

# ダブリング dp[i][j]:=jから2**i回遷移したときの到達点
# https://atcoder.jp/contests/abc167/submissions/40815296
# N,K=map(int,input().split())
# A=list(map(int,input().split()))
# dp=[[-1]*N for _ in range(60)]
# for j in range(N):
#     dp[0][j]=A[j]-1
# for i in range(1,60):
#     for j in range(N):
#         dp[i][j]=dp[i-1][dp[i-1][j]]
# i=0
# now=0
# while(K>0):
#     if (K&1)==1:
#         now=dp[i][now]
#     i+=1
#     K>>=1
# print(now+1)

dxdy1 = ((0, 1), (0, -1), (1, 0), (-1, 0))
dxdy2 = ((0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1))
dxdy3 = ((0, 1), (1, 0))
dxdy4 = ((1, 1), (1, -1), (-1, 1), (-1, -1))
INF = float("inf")
MOD = 998244353
mod = 998244353
# memo : len([a,b,...,z])==26

Q = int(input())


def count_lattice_points_in_circle(r, K):
    count = 0
    c2 = 0
    rr = int(r**0.5)
    for x in range(-K, K + 1):
        for y in range(-K, K + 1):
            if x + y != K:
                continue

    return count, c2


for i in range(Q):
    D, K = map(int, input().split())
    ok = False
    kouho = defaultdict(int)
    dist = []
    view = defaultdict(int)
    for x in range(D + 1):
        y = D - x
        for dx, dy in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
            nx = x * dx
            ny = y * dy
            if view[nx, ny] != 0:
                continue
            view[nx, ny] = 1
            kouho[nx, ny] = x**2 + y**2
            dist.append(x**2 + y**2)
    dist.sort()
    for key, val in kouho.items():
        point = bisect.bisect_left(dist, val)
        p2 = bisect.bisect_left(dist, val + 1)
        # print(i, key, point, p2)
        if point < K and p2 >= K:
            print("Yes")
            print(*key)
            ok = True
            break
    if not ok:
        print("No")
0