結果
問題 | No.2541 Divide 01 String |
ユーザー | flygon |
提出日時 | 2023-11-24 21:23:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 66,000 KB |
最終ジャッジ日時 | 2023-11-24 21:23:03 |
合計ジャッジ時間 | 2,612 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
55,720 KB |
testcase_01 | AC | 42 ms
55,720 KB |
testcase_02 | AC | 41 ms
55,720 KB |
testcase_03 | AC | 50 ms
62,156 KB |
testcase_04 | AC | 50 ms
62,568 KB |
testcase_05 | AC | 53 ms
65,720 KB |
testcase_06 | AC | 50 ms
62,432 KB |
testcase_07 | AC | 53 ms
65,704 KB |
testcase_08 | AC | 54 ms
65,992 KB |
testcase_09 | AC | 54 ms
65,864 KB |
testcase_10 | AC | 49 ms
63,736 KB |
testcase_11 | AC | 52 ms
66,000 KB |
testcase_12 | AC | 53 ms
66,000 KB |
testcase_13 | AC | 45 ms
55,720 KB |
testcase_14 | AC | 41 ms
55,720 KB |
testcase_15 | AC | 42 ms
55,720 KB |
testcase_16 | AC | 42 ms
55,720 KB |
testcase_17 | AC | 42 ms
55,720 KB |
testcase_18 | AC | 48 ms
62,780 KB |
testcase_19 | AC | 48 ms
62,776 KB |
testcase_20 | AC | 47 ms
62,772 KB |
testcase_21 | AC | 47 ms
62,528 KB |
testcase_22 | AC | 47 ms
62,508 KB |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) s = input().rstrip() dp = [0]*(n+1) dp[0] = 1 last = -1 for i in range(1,n+1): if s[i-1] == "1": dp[i] += dp[i-1] last = i elif last != -1: dp[i] += dp[last-1] dp[i] += dp[i-1] dp[i] %= 998244353 print((dp[-1]-dp[-2])%998244353)