Submission #14498885


Source Code Expand

Copy
import sys
import numpy as np
from functools import lru_cache

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

MOD = 998_244_353

def main(A, B, C, D):
    dp = np.zeros((C + 1, D + 1), np.int64)
    dp[C, D] = 1
    for d in range(D, 0, -1):
        dp[C, d - 1] = dp[C, d] * C % MOD
    for c in range(C - 1, -1, -1):
        x = 0
        for d in range(D, -1, -1):
            dp[c, d] = (d * dp[c + 1, d] + x) % MOD
            x += dp[c + 1, d]
            x *= c
            x %= MOD
    return dp[A, B]

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

A, B, C, D = map(int, read().split())
print(main(A, B, C, D))

Submission Info

Submission Time
Task B - Extension
User maspy
Language Python (3.8.2)
Score 600
Code Size 930 Byte
Status
Exec Time 220 ms
Memory 97052 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 600 / 600 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 220 ms 97052 KB
02.txt 219 ms 96920 KB
03.txt 117 ms 27184 KB
04.txt 116 ms 27184 KB
05.txt 211 ms 92436 KB
06.txt 214 ms 96920 KB
07.txt 155 ms 49752 KB
08.txt 187 ms 75888 KB
09.txt 126 ms 27188 KB
10.txt 184 ms 70008 KB
11.txt 124 ms 29976 KB
12.txt 220 ms 96576 KB
13.txt 207 ms 89064 KB
14.txt 125 ms 26808 KB
s1.txt 117 ms 27124 KB
s2.txt 117 ms 27344 KB
s3.txt 120 ms 27244 KB