結果
問題 | No.2867 NOT FOUND 404 Again |
ユーザー | LyricalMaestro |
提出日時 | 2024-09-21 19:45:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,072 bytes |
コンパイル時間 | 387 ms |
コンパイル使用メモリ | 82,012 KB |
実行使用メモリ | 174,736 KB |
最終ジャッジ日時 | 2024-09-21 19:45:26 |
合計ジャッジ時間 | 8,207 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
51,968 KB |
testcase_01 | AC | 39 ms
51,968 KB |
testcase_02 | AC | 42 ms
52,096 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 249 ms
169,596 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 277 ms
173,660 KB |
testcase_19 | AC | 920 ms
174,736 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 == 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()