結果
問題 | No.2437 Fragile Multiples of 11 |
ユーザー | chineristAC |
提出日時 | 2023-08-19 00:06:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 94 ms / 2,000 ms |
コード長 | 2,674 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 76,800 KB |
最終ジャッジ日時 | 2024-05-06 06:59:32 |
合計ジャッジ時間 | 3,879 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
67,584 KB |
testcase_01 | AC | 67 ms
67,712 KB |
testcase_02 | AC | 67 ms
68,096 KB |
testcase_03 | AC | 80 ms
73,088 KB |
testcase_04 | AC | 80 ms
73,216 KB |
testcase_05 | AC | 90 ms
76,544 KB |
testcase_06 | AC | 91 ms
76,288 KB |
testcase_07 | AC | 91 ms
76,288 KB |
testcase_08 | AC | 90 ms
76,672 KB |
testcase_09 | AC | 92 ms
76,672 KB |
testcase_10 | AC | 92 ms
76,544 KB |
testcase_11 | AC | 94 ms
76,544 KB |
testcase_12 | AC | 91 ms
76,416 KB |
testcase_13 | AC | 91 ms
76,672 KB |
testcase_14 | AC | 91 ms
76,544 KB |
testcase_15 | AC | 66 ms
67,456 KB |
testcase_16 | AC | 66 ms
67,712 KB |
testcase_17 | AC | 74 ms
67,456 KB |
testcase_18 | AC | 71 ms
67,456 KB |
testcase_19 | AC | 65 ms
67,456 KB |
testcase_20 | AC | 66 ms
67,840 KB |
testcase_21 | AC | 68 ms
67,584 KB |
testcase_22 | AC | 66 ms
67,840 KB |
testcase_23 | AC | 69 ms
67,968 KB |
testcase_24 | AC | 74 ms
70,016 KB |
testcase_25 | AC | 68 ms
68,224 KB |
testcase_26 | AC | 70 ms
68,224 KB |
testcase_27 | AC | 76 ms
70,656 KB |
testcase_28 | AC | 93 ms
76,416 KB |
testcase_29 | AC | 93 ms
76,800 KB |
testcase_30 | AC | 90 ms
76,416 KB |
testcase_31 | AC | 89 ms
76,416 KB |
testcase_32 | AC | 85 ms
74,240 KB |
testcase_33 | AC | 75 ms
69,888 KB |
ソースコード
import sys from itertools import permutations from heapq import * input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = self.segfunc(self.tree[k],x) while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res mod = 998244353 M = 110 ans = [0] * (M+1) for k in range(1,M+1): dp = [[0]*11 for i in range(k)] for d in range(1,10): dp[0][d] = 1 for i in range(1,k): for pre_m in range(11): for d in range(10): if (2*pre_m-d)%11: dp[i][(d-pre_m)%11] += dp[i-1][pre_m] dp[i][(d-pre_m)%11] %= mod ans[k] = dp[k-1][0] N = int(input()) X = str(int(input())+1) N = len(X) res = 0 for k in range(1,N): res += ans[k] dp = [[[0]*11 for i in range(N)] for p in range(2)] for d in range(1,int(X[0])): dp[1][0][d] = 1 dp[0][0][int(X[0])] = 1 for i in range(1,N): x = int(X[i]) for d in range(x): for pre_m in range(11): if ((2*pre_m-d)%11!=0): dp[1][i][(d-pre_m)%11] += dp[0][i-1][pre_m] dp[1][i][(d-pre_m)%11] += dp[1][i-1][pre_m] dp[1][i][(d-pre_m)%11] %= mod for d in range(x,10): for pre_m in range(11): if ((2*pre_m-d)%11!=0): if d == x: dp[0][i][(d-pre_m)%11] += dp[0][i-1][pre_m] dp[1][i][(d-pre_m)%11] += dp[1][i-1][pre_m] dp[0][i][(d-pre_m)%11] %= mod dp[1][i][(d-pre_m)%11] %= mod res += dp[1][N-1][0] res %= mod print(res)