結果

問題 No.398 ハーフパイプ(2)
ユーザー rlangevinrlangevin
提出日時 2023-11-02 18:30:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,364 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 11,964 KB
実行使用メモリ 78,440 KB
最終ジャッジ日時 2023-11-02 18:30:56
合計ジャッジ時間 24,100 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,364 ms
78,440 KB
testcase_01 AC 1,309 ms
78,440 KB
testcase_02 AC 1,364 ms
78,440 KB
testcase_03 AC 1,344 ms
78,440 KB
testcase_04 AC 1,350 ms
78,440 KB
testcase_05 AC 1,259 ms
78,440 KB
testcase_06 AC 1,216 ms
78,440 KB
testcase_07 AC 1,200 ms
78,440 KB
testcase_08 AC 1,189 ms
78,440 KB
testcase_09 AC 1,176 ms
78,440 KB
testcase_10 AC 1,223 ms
78,440 KB
testcase_11 AC 1,276 ms
78,440 KB
testcase_12 AC 1,221 ms
78,440 KB
testcase_13 AC 1,191 ms
78,440 KB
testcase_14 AC 1,180 ms
78,440 KB
testcase_15 AC 1,209 ms
78,440 KB
testcase_16 AC 1,212 ms
78,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def convolve(f, g):
    fft_len = 1
    while 2 * fft_len < len(f) + len(g) - 1:
        fft_len *= 2
    fft_len *= 2
    Ff = np.fft.rfft(f, fft_len)
    Fg = np.fft.rfft(g, fft_len)
    Fh = Ff * Fg
    h = np.fft.irfft(Fh, fft_len)
    h = np.rint(h).astype(np.int64)

    return h[:len(f) + len(g) - 1]

a, b = input().split(".")
X = int(a + b)//25

M = 100
S = set()
ans = int(X % 4 == 0)
memo = [[0] * (M + 1) for i in range(M + 1)]
for a in range(M + 1):
    for b in range(a, M + 1):
        dp = [0] * (M + 1)
        for i in range(a, b + 1):
            dp[i] = 1
        temp2 = convolve(dp, dp)
        temp4 = convolve(temp2, temp2)
        temp6 = convolve(temp4, temp2)
        memo[a][b] = temp6
        S.add((a,b))


for a in range(M + 1):
    for b in range(a + 1, M + 1):
        if X + a + b >= 6 * b:
            continue
        if X + a + b <= 6 * a:
            continue
        ans += memo[a][b][X + a + b]
        if (a,b-1) in S:
            ans -= memo[a][b-1][X + a + b]
        if (a+1,b) in S:
            ans -= memo[a+1][b][X + a + b]
        if (a+1,b-1) in S:
            ans += memo[a+1][b-1][X + a + b]

print(ans)
0