結果

問題 No.398 ハーフパイプ(2)
ユーザー rlangevinrlangevin
提出日時 2023-11-02 12:59:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,345 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,060 KB
実行使用メモリ 42,440 KB
最終ジャッジ日時 2023-11-02 13:00:12
合計ジャッジ時間 33,585 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,093 ms
42,440 KB
testcase_01 AC 1,078 ms
42,440 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 1,711 ms
42,440 KB
testcase_06 AC 1,639 ms
42,440 KB
testcase_07 AC 1,972 ms
42,440 KB
testcase_08 AC 1,054 ms
42,440 KB
testcase_09 AC 1,796 ms
42,440 KB
testcase_10 AC 1,763 ms
42,440 KB
testcase_11 AC 1,649 ms
42,440 KB
testcase_12 AC 1,982 ms
42,440 KB
testcase_13 AC 1,947 ms
42,440 KB
testcase_14 TLE -
testcase_15 AC 1,475 ms
42,440 KB
testcase_16 TLE -
権限があれば一括ダウンロードができます

ソースコード

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
ans = int(X % 4 == 0)
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
        dp = [0] * (M + 1)
        for i in range(a, b + 1):
            dp[i] = 1
        temp = [0] * (M + 1)
        temp[0] = 1
        for _ in range(3):
            temp = convolve(temp, dp)
        temp = convolve(temp, temp)
        ans += temp[X + a + b]

        dp[b] = 0
        temp2 = convolve(dp, dp)
        temp4 = convolve(temp2, temp2)
        temp6 = convolve(temp4, temp2)
        ans -= temp6[X + a + b]

        dp[a] = 0
        dp[b] = 1
        temp2 = convolve(dp, dp)
        temp4 = convolve(temp2, temp2)
        temp6 = convolve(temp4, temp2)
        ans -= temp6[X + a + b]

        dp[b] = 0
        temp2 = convolve(dp, dp)
        temp4 = convolve(temp2, temp2)
        temp6 = convolve(temp4, temp2)
        ans += temp6[X + a + b]

print(ans)
0