結果

問題 No.2219 Re:010
ユーザー maguroflymagurofly
提出日時 2023-02-17 22:11:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 16,288 KB
最終ジャッジ日時 2023-09-26 19:27:20
合計ジャッジ時間 4,831 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,208 KB
testcase_01 AC 81 ms
15,032 KB
testcase_02 AC 81 ms
15,116 KB
testcase_03 AC 137 ms
15,552 KB
testcase_04 AC 90 ms
15,364 KB
testcase_05 AC 125 ms
15,568 KB
testcase_06 AC 94 ms
15,268 KB
testcase_07 AC 109 ms
15,468 KB
testcase_08 AC 134 ms
15,708 KB
testcase_09 AC 133 ms
15,560 KB
testcase_10 AC 121 ms
15,776 KB
testcase_11 AC 114 ms
15,684 KB
testcase_12 AC 115 ms
15,436 KB
testcase_13 AC 148 ms
15,780 KB
testcase_14 AC 147 ms
15,688 KB
testcase_15 AC 148 ms
15,720 KB
testcase_16 AC 145 ms
15,868 KB
testcase_17 AC 148 ms
15,576 KB
testcase_18 AC 134 ms
15,636 KB
testcase_19 AC 127 ms
15,716 KB
testcase_20 AC 169 ms
16,288 KB
testcase_21 AC 81 ms
15,288 KB
testcase_22 AC 82 ms
15,204 KB
testcase_23 AC 81 ms
15,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chomp
MOD = 998244353

a, b, c, d = 1, 0, 0, 0
S.each_char do |ch|
    case ch
    when ?0
        d += c
        b += a
        a %= MOD
        d %= MOD
    when ?1
        c += b
        c %= MOD
    when ??
        a0, b0, c0, d0 = a, b + a, c, d + c
        a1, b1, c1, d1 = a, b, c + b, d
        a, b, c, d = (a0 + a1) % MOD, (b0 + b1) % MOD, (c0 + c1) % MOD, (d0 + d1) % MOD
    end
end

puts d
0