Submission #49170411
Source Code Expand
Copy
#ABC335F Hop Sugoroku_平方分割#入力受取 1-indexedN = int(input())A = [0] + list(map(int,input().split()))MOD = 998244353#DP[i]: コマの位置がiとなるときの、塗り方の場合の数DP = [0] * (N+1)DP[1] = 1#平方分割(stepが小さい側) G[x][y]: y mod xのマスに移動する場合の数の総和sqrt_N = int(N**0.5)G = [[0]*x for x in range(sqrt_N + 1)]#遷移for now in range(1, N+1):#stepが小さいものを受け取るfor x in range(1, sqrt_N + 1):y = now % xDP[now] += G[x][y]
#ABC335F Hop Sugoroku_平方分割 #入力受取 1-indexed N = int(input()) A = [0] + list(map(int,input().split())) MOD = 998244353 #DP[i]: コマの位置がiとなるときの、塗り方の場合の数 DP = [0] * (N+1) DP[1] = 1 #平方分割(stepが小さい側) G[x][y]: y mod xのマスに移動する場合の数の総和 sqrt_N = int(N**0.5) G = [[0]*x for x in range(sqrt_N + 1)] #遷移 for now in range(1, N+1): #stepが小さいものを受け取る for x in range(1, sqrt_N + 1): y = now % x DP[now] += G[x][y] DP[now] %= MOD #A[now]の大小で場合分けして遷移 if A[now] <= sqrt_N: #小さい場合 G[A[now]][now % A[now]] += DP[now] G[A[now]][now % A[now]] %= MOD else: #大きい場合 for next in range(now + A[now], N+1, A[now]): DP[next] += DP[now] #答えを出力 print(sum(DP) % MOD)
Submission Info
Submission Time | |
---|---|
Task | F - Hop Sugoroku |
User | navel_tos |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 525 |
Code Size | 934 Byte |
Status | AC |
Exec Time | 658 ms |
Memory | 117624 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 525 / 525 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 56 ms | 76516 KB |
sample_02.txt | AC | 56 ms | 76000 KB |
sample_03.txt | AC | 56 ms | 76420 KB |
test_01.txt | AC | 56 ms | 76256 KB |
test_02.txt | AC | 612 ms | 114648 KB |
test_03.txt | AC | 615 ms | 114676 KB |
test_04.txt | AC | 612 ms | 114916 KB |
test_05.txt | AC | 569 ms | 117528 KB |
test_06.txt | AC | 571 ms | 117624 KB |
test_07.txt | AC | 568 ms | 116920 KB |
test_08.txt | AC | 568 ms | 117212 KB |
test_09.txt | AC | 574 ms | 117380 KB |
test_10.txt | AC | 564 ms | 117260 KB |
test_11.txt | AC | 658 ms | 115768 KB |
test_12.txt | AC | 606 ms | 115692 KB |
test_13.txt | AC | 606 ms | 115948 KB |
test_14.txt | AC | 607 ms | 115884 KB |
test_15.txt | AC | 609 ms | 116100 KB |
test_16.txt | AC | 604 ms | 116084 KB |
test_17.txt | AC | 604 ms | 115640 KB |
test_18.txt | AC | 607 ms | 115536 KB |
test_19.txt | AC | 604 ms | 115664 KB |
test_20.txt | AC | 609 ms | 115808 KB |
test_21.txt | AC | 577 ms | 117368 KB |
test_22.txt | AC | 560 ms | 117392 KB |
test_23.txt | AC | 561 ms | 117524 KB |
test_24.txt | AC | 561 ms | 117464 KB |
test_25.txt | AC | 563 ms | 117312 KB |
test_26.txt | AC | 557 ms | 117148 KB |
test_27.txt | AC | 556 ms | 117276 KB |
test_28.txt | AC | 584 ms | 117264 KB |
test_29.txt | AC | 562 ms | 117396 KB |
test_30.txt | AC | 555 ms | 117216 KB |
test_31.txt | AC | 581 ms | 116384 KB |
test_32.txt | AC | 565 ms | 116744 KB |
test_33.txt | AC | 583 ms | 116388 KB |
test_34.txt | AC | 562 ms | 116460 KB |
test_35.txt | AC | 575 ms | 116552 KB |
test_36.txt | AC | 585 ms | 116564 KB |
test_37.txt | AC | 565 ms | 116656 KB |
test_38.txt | AC | 575 ms | 116344 KB |
test_39.txt | AC | 578 ms | 116528 KB |
test_40.txt | AC | 574 ms | 116676 KB |
test_41.txt | AC | 577 ms | 116840 KB |
test_42.txt | AC | 100 ms | 85476 KB |
test_43.txt | AC | 310 ms | 100796 KB |
test_44.txt | AC | 412 ms | 109392 KB |
test_45.txt | AC | 79 ms | 82776 KB |
test_46.txt | AC | 444 ms | 109492 KB |
test_47.txt | AC | 391 ms | 106588 KB |
test_48.txt | AC | 339 ms | 103752 KB |
test_49.txt | AC | 218 ms | 95312 KB |
test_50.txt | AC | 543 ms | 116872 KB |
test_51.txt | AC | 610 ms | 114732 KB |
test_52.txt | AC | 615 ms | 114592 KB |
test_53.txt | AC | 613 ms | 114712 KB |
test_54.txt | AC | 613 ms | 114720 KB |
test_55.txt | AC | 620 ms | 114720 KB |
test_56.txt | AC | 614 ms | 114564 KB |
test_57.txt | AC | 612 ms | 114760 KB |
test_58.txt | AC | 617 ms | 114564 KB |
test_59.txt | AC | 615 ms | 114824 KB |
test_60.txt | AC | 613 ms | 115020 KB |