結果

問題 No.869 ふたつの距離
ユーザー maspymaspy
提出日時 2020-05-14 14:57:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,806 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 11,092 KB
実行使用メモリ 31,140 KB
最終ジャッジ日時 2023-10-13 10:00:33
合計ジャッジ時間 28,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
30,064 KB
testcase_01 AC 127 ms
30,024 KB
testcase_02 AC 127 ms
30,112 KB
testcase_03 AC 128 ms
29,968 KB
testcase_04 AC 132 ms
30,028 KB
testcase_05 AC 133 ms
30,004 KB
testcase_06 AC 129 ms
29,952 KB
testcase_07 AC 127 ms
30,016 KB
testcase_08 AC 130 ms
29,968 KB
testcase_09 AC 130 ms
30,032 KB
testcase_10 AC 126 ms
30,068 KB
testcase_11 AC 128 ms
30,072 KB
testcase_12 AC 126 ms
30,088 KB
testcase_13 AC 129 ms
30,032 KB
testcase_14 AC 129 ms
29,944 KB
testcase_15 AC 127 ms
30,020 KB
testcase_16 AC 133 ms
30,028 KB
testcase_17 AC 132 ms
29,980 KB
testcase_18 AC 128 ms
29,976 KB
testcase_19 AC 130 ms
29,968 KB
testcase_20 AC 127 ms
30,104 KB
testcase_21 AC 126 ms
29,952 KB
testcase_22 AC 127 ms
30,028 KB
testcase_23 AC 129 ms
30,020 KB
testcase_24 AC 127 ms
30,024 KB
testcase_25 AC 128 ms
30,060 KB
testcase_26 AC 129 ms
29,968 KB
testcase_27 AC 131 ms
29,952 KB
testcase_28 AC 132 ms
29,984 KB
testcase_29 AC 133 ms
30,024 KB
testcase_30 AC 128 ms
29,928 KB
testcase_31 AC 123 ms
30,140 KB
testcase_32 AC 126 ms
30,116 KB
testcase_33 AC 128 ms
30,048 KB
testcase_34 AC 124 ms
30,036 KB
testcase_35 AC 126 ms
30,056 KB
testcase_36 AC 128 ms
29,956 KB
testcase_37 AC 125 ms
30,044 KB
testcase_38 AC 128 ms
30,108 KB
testcase_39 AC 130 ms
30,080 KB
testcase_40 AC 127 ms
30,028 KB
testcase_41 AC 132 ms
30,108 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 AC 130 ms
30,116 KB
testcase_94 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

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

def solve_1d(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, 1, n + 1)[::-1]
    dx = 1 / (n + n)
    y = []
    for i in range(m):
        t = min(n, A)
        A -= t
        y.append(10 + x[t] + dx)
    x = np.concatenate([x[:-1], y])
    assert len(x) == N
    cnt = 0
    for i in range(N):
        cnt += np.sum(np.abs(x[i] - x[i + 1:]) < 10)
    assert cnt == A0
    return x

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)
    t = solve_1d(n - 1, A)
    theta = t / 20
    x = np.cos(theta) * 20
    y = np.sin(theta) * 20
    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)

def check(N, A, B, x, y):
    assert len(x) == len(y) == N
    dx = np.subtract.outer(x, x)
    dy = np.subtract.outer(y, y)
    d = (dx * dx + dy * dy)**.5
    np.fill_diagonal(d, 30)
    n1 = np.count_nonzero(d <= 10) // 2
    n2 = np.count_nonzero(d <= 20) // 2
    assert n1 == A
    assert n2 == B

# check(N, A, B, x, y)

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