結果
問題 | No.2867 NOT FOUND 404 Again |
ユーザー | LyricalMaestro |
提出日時 | 2024-09-21 19:47:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 863 ms / 3,000 ms |
コード長 | 2,134 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 174,228 KB |
最終ジャッジ日時 | 2024-09-21 19:47:30 |
合計ジャッジ時間 | 6,406 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
51,840 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 38 ms
51,968 KB |
testcase_03 | AC | 273 ms
169,988 KB |
testcase_04 | AC | 253 ms
169,188 KB |
testcase_05 | AC | 271 ms
170,008 KB |
testcase_06 | AC | 254 ms
169,572 KB |
testcase_07 | AC | 265 ms
169,856 KB |
testcase_08 | AC | 269 ms
169,732 KB |
testcase_09 | AC | 255 ms
168,968 KB |
testcase_10 | AC | 256 ms
169,208 KB |
testcase_11 | AC | 269 ms
170,264 KB |
testcase_12 | AC | 271 ms
170,480 KB |
testcase_13 | AC | 275 ms
170,252 KB |
testcase_14 | AC | 263 ms
169,936 KB |
testcase_15 | AC | 267 ms
170,268 KB |
testcase_16 | AC | 252 ms
168,728 KB |
testcase_17 | AC | 263 ms
170,184 KB |
testcase_18 | AC | 274 ms
173,560 KB |
testcase_19 | AC | 863 ms
174,228 KB |
ソースコード
## https://yukicoder.me/problems/no/2867 MOD = 998244353 def main(): N = input() n_len = len(N) dp_not_contains = [[0] * 3 for _ in range(n_len)] dp_not_contains[0][0] = 9 dp_not_contains[0][1] = 1 for i in range(1, n_len): dp_not_contains[i][0] += (9 * dp_not_contains[i - 1][0]) % MOD dp_not_contains[i][0] %= MOD dp_not_contains[i][1] += (1 * dp_not_contains[i - 1][0]) % MOD dp_not_contains[i][1] %= MOD dp_not_contains[i][2] += (1 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][2] %= MOD dp_not_contains[i][1] += (1 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][1] %= MOD dp_not_contains[i][0] += (8 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][0] %= MOD dp_not_contains[i][0] += (9 * dp_not_contains[i - 1][2]) % MOD dp_not_contains[i][0] %= MOD answers = 0 n_state = 0 for i in range(n_len): n = int(N[i]) ans = 0 if i < n_len - 1: for j in range(n): for k in range(3): if k == 2 and j == 4: continue if k == 1 and n_state == 1 and j == 0: continue if n_state == 2 and j == 4: continue ans += dp_not_contains[n_len - 2 - i][k] ans %= MOD elif i == n_len - 1: for j in range(n): if n_state == 2 and j == 4: continue ans += 1 ans %= MOD answers += ans answers %= MOD if n_state == 0 and n == 4: n_state = 1 elif n_state == 1 and n == 0: n_state = 2 elif n_state == 1 and n == 4: n_state = 1 elif n_state == 2 and n == 4: break else: n_state = 0 if "404" not in N: answers += 1 answers %= MOD # 最後の0は消す print((answers - 1) % MOD) if __name__ == "__main__": main()