結果

問題 No.869 ふたつの距離
ユーザー maspymaspy
提出日時 2020-05-14 15:08:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 147 ms / 1,500 ms
コード長 1,347 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 30,456 KB
最終ジャッジ日時 2023-10-13 10:17:35
合計ジャッジ時間 22,802 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
29,668 KB
testcase_01 AC 133 ms
29,936 KB
testcase_02 AC 134 ms
29,844 KB
testcase_03 AC 135 ms
29,912 KB
testcase_04 AC 136 ms
29,668 KB
testcase_05 AC 136 ms
29,848 KB
testcase_06 AC 135 ms
29,824 KB
testcase_07 AC 134 ms
29,820 KB
testcase_08 AC 134 ms
29,740 KB
testcase_09 AC 136 ms
29,916 KB
testcase_10 AC 137 ms
29,948 KB
testcase_11 AC 138 ms
29,856 KB
testcase_12 AC 139 ms
29,812 KB
testcase_13 AC 136 ms
29,752 KB
testcase_14 AC 136 ms
29,868 KB
testcase_15 AC 137 ms
29,888 KB
testcase_16 AC 142 ms
29,836 KB
testcase_17 AC 137 ms
29,736 KB
testcase_18 AC 139 ms
29,836 KB
testcase_19 AC 137 ms
29,824 KB
testcase_20 AC 140 ms
29,780 KB
testcase_21 AC 138 ms
29,824 KB
testcase_22 AC 143 ms
29,824 KB
testcase_23 AC 142 ms
29,668 KB
testcase_24 AC 140 ms
29,784 KB
testcase_25 AC 139 ms
29,932 KB
testcase_26 AC 137 ms
29,896 KB
testcase_27 AC 146 ms
29,776 KB
testcase_28 AC 141 ms
29,864 KB
testcase_29 AC 140 ms
29,812 KB
testcase_30 AC 136 ms
29,820 KB
testcase_31 AC 138 ms
29,864 KB
testcase_32 AC 141 ms
29,656 KB
testcase_33 AC 138 ms
29,664 KB
testcase_34 AC 143 ms
29,784 KB
testcase_35 AC 143 ms
29,712 KB
testcase_36 AC 138 ms
29,720 KB
testcase_37 AC 138 ms
29,748 KB
testcase_38 AC 133 ms
29,908 KB
testcase_39 AC 135 ms
29,724 KB
testcase_40 AC 132 ms
29,776 KB
testcase_41 AC 134 ms
29,748 KB
testcase_42 AC 138 ms
30,044 KB
testcase_43 AC 140 ms
30,120 KB
testcase_44 AC 138 ms
29,964 KB
testcase_45 AC 139 ms
30,148 KB
testcase_46 AC 136 ms
29,840 KB
testcase_47 AC 138 ms
30,032 KB
testcase_48 AC 140 ms
30,092 KB
testcase_49 AC 139 ms
30,112 KB
testcase_50 AC 138 ms
30,012 KB
testcase_51 AC 138 ms
29,888 KB
testcase_52 AC 137 ms
29,788 KB
testcase_53 AC 137 ms
29,960 KB
testcase_54 AC 144 ms
29,968 KB
testcase_55 AC 144 ms
30,188 KB
testcase_56 AC 138 ms
29,892 KB
testcase_57 AC 142 ms
29,964 KB
testcase_58 AC 137 ms
30,000 KB
testcase_59 AC 139 ms
30,064 KB
testcase_60 AC 141 ms
30,220 KB
testcase_61 AC 140 ms
30,016 KB
testcase_62 AC 142 ms
30,260 KB
testcase_63 AC 142 ms
30,360 KB
testcase_64 AC 140 ms
29,992 KB
testcase_65 AC 141 ms
29,988 KB
testcase_66 AC 138 ms
30,244 KB
testcase_67 AC 141 ms
30,456 KB
testcase_68 AC 141 ms
30,024 KB
testcase_69 AC 142 ms
30,296 KB
testcase_70 AC 143 ms
30,272 KB
testcase_71 AC 146 ms
30,264 KB
testcase_72 AC 144 ms
30,252 KB
testcase_73 AC 144 ms
30,204 KB
testcase_74 AC 141 ms
30,120 KB
testcase_75 AC 144 ms
30,156 KB
testcase_76 AC 143 ms
30,268 KB
testcase_77 AC 141 ms
30,208 KB
testcase_78 AC 142 ms
30,212 KB
testcase_79 AC 140 ms
30,348 KB
testcase_80 AC 141 ms
30,188 KB
testcase_81 AC 144 ms
29,952 KB
testcase_82 AC 144 ms
30,140 KB
testcase_83 AC 139 ms
30,016 KB
testcase_84 AC 141 ms
30,128 KB
testcase_85 AC 141 ms
30,336 KB
testcase_86 AC 147 ms
30,296 KB
testcase_87 AC 141 ms
30,200 KB
testcase_88 AC 141 ms
30,332 KB
testcase_89 AC 142 ms
30,104 KB
testcase_90 AC 141 ms
30,352 KB
testcase_91 AC 147 ms
30,172 KB
testcase_92 AC 145 ms
30,284 KB
testcase_93 AC 135 ms
29,744 KB
testcase_94 AC 135 ms
29,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def solve_on_circ(N, A):
    A0 = A
    n = (N + 1) // 2
    m = N - n
    A -= n * (n - 1) // 2 + m * (m - 1) // 2
    assert A >= 0
    x = np.linspace(0, 0.1, n + 1)[::-1]
    dx = 0.1 / (n + n)
    y = []
    phi = 2 * np.arcsin(0.25)
    for i in range(m):
        t = min(n, A)
        A -= t
        y.append(phi + x[t] + dx)
    t = np.concatenate([x[:-1], y])
    x = 20 * np.cos(t)
    y = 20 * np.sin(t)
    return x, y

def other_points(M):
    x = np.linspace(100, 90000, M)
    y = np.zeros_like(x)
    return x, y

def solve(N, A, B):
    left = 0  # B 未満
    right = N  # B以上
    while left + 1 < right:
        x = (left + right) // 2
        if x * (x - 1) // 2 >= B:
            right = x
        else:
            left = x
    n = right
    x0, y0 = other_points(N - n)
    x, y = solve_on_circ(n - 1, A)
    far = n * (n - 1) // 2 - B
    eps = 1e-7
    x[:far] *= (1 + eps)
    y[:far] *= (1 + eps)
    x[far:] *= (1 - eps)
    y[far:] *= (1 - eps)
    x = np.concatenate([[0], x, x0])
    y = np.concatenate([[0], y, y0])
    return x, y

N, A, B = map(int, read().split())

x, y = solve(N, A, B)
xy = np.vstack([x, y]).T
print('\n'.join(' '.join(row) for row in xy.astype(str)))
0