結果
| 問題 |
No.1964 sum = length
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2022-06-03 22:06:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,664 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,136 KB |
| 実行使用メモリ | 217,484 KB |
| 最終ジャッジ日時 | 2024-09-21 02:46:20 |
| 合計ジャッジ時間 | 35,697 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 TLE * 2 |
ソースコード
import sys
# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353
n = II()
m = n+230
dp = [[0]*m for _ in range(m)]
ss = [[0]*(m+1) for _ in range(m)]
dp[0][0] = 1
ss[0] = [0]+[1]*m
for t in range(n):
ndp = [[0]*m for _ in range(m)]
nss = [[0]*(m+1) for _ in range(m)]
for i in range(1, m):
for j in range(1, m):
# ndp[i][j] += sum(dp[i-2][j-1, j-9])
l, pi = max(0, j-9), i-2+(t == 0)
if pi >= 0: ndp[i][j] += ss[pi][j]-ss[pi][l]
# ndp[i][j] += sum(dp[i-3][j-10, j-99])
l, pi = max(0, j-99), i-3+(t == 0)
if pi >= 0 and j-9>=0: ndp[i][j] += ss[pi][j-9]-ss[pi][l]
# ndp[i][j] += sum(dp[i-4][j-100, j-999])
l, pi = max(0, j-999), i-4+(t == 0)
if pi >= 0 and j-99>=0: ndp[i][j] += ss[pi][j-99]-ss[pi][l]
nss[i][j+1] = (nss[i][j]+ndp[i][j])%md
dp,ss=ndp,nss
# p2D(dp)
ans=0
for i in range(m):
# print(i,dp[i][i])
ans+=dp[i][i]
ans%=md
print(ans)
mkawa2