結果

問題 No.2541 Divide 01 String
ユーザー ShirotsumeShirotsume
提出日時 2023-07-21 00:04:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,832 KB
最終ジャッジ日時 2023-12-01 03:41:19
合計ジャッジ時間 2,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
56,268 KB
testcase_01 AC 42 ms
56,268 KB
testcase_02 AC 42 ms
56,268 KB
testcase_03 AC 48 ms
62,324 KB
testcase_04 AC 48 ms
62,324 KB
testcase_05 AC 49 ms
62,664 KB
testcase_06 AC 48 ms
62,324 KB
testcase_07 AC 49 ms
62,660 KB
testcase_08 AC 53 ms
64,832 KB
testcase_09 AC 48 ms
62,684 KB
testcase_10 AC 45 ms
62,576 KB
testcase_11 AC 46 ms
62,576 KB
testcase_12 AC 46 ms
64,708 KB
testcase_13 AC 41 ms
56,268 KB
testcase_14 AC 41 ms
56,268 KB
testcase_15 AC 42 ms
56,268 KB
testcase_16 AC 41 ms
56,268 KB
testcase_17 AC 42 ms
56,268 KB
testcase_18 AC 42 ms
56,268 KB
testcase_19 AC 42 ms
56,268 KB
testcase_20 AC 40 ms
56,268 KB
testcase_21 AC 42 ms
56,268 KB
testcase_22 AC 41 ms
56,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

s = input()

if '1' not in s:
    print(0)
else:
    bef = -1
    ans = 1
    for i in range(n):
        if s[i] == '1':
            if bef == -1:
                bef = i
            else:
                ans *= (i - bef + 1)
                ans %= mod
                bef = i
    print(ans)
0