結果
問題 | No.2279 OR Insertion |
ユーザー | chineristAC |
提出日時 | 2023-04-21 21:45:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 539 ms / 2,000 ms |
コード長 | 2,127 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 80,568 KB |
最終ジャッジ日時 | 2024-11-06 15:15:21 |
合計ジャッジ時間 | 16,596 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
68,736 KB |
testcase_01 | AC | 69 ms
69,248 KB |
testcase_02 | AC | 145 ms
78,780 KB |
testcase_03 | AC | 114 ms
79,272 KB |
testcase_04 | AC | 477 ms
79,944 KB |
testcase_05 | AC | 95 ms
78,692 KB |
testcase_06 | AC | 246 ms
79,144 KB |
testcase_07 | AC | 258 ms
79,360 KB |
testcase_08 | AC | 147 ms
79,104 KB |
testcase_09 | AC | 315 ms
79,360 KB |
testcase_10 | AC | 465 ms
79,740 KB |
testcase_11 | AC | 137 ms
79,328 KB |
testcase_12 | AC | 385 ms
79,348 KB |
testcase_13 | AC | 108 ms
78,664 KB |
testcase_14 | AC | 111 ms
78,592 KB |
testcase_15 | AC | 274 ms
79,388 KB |
testcase_16 | AC | 95 ms
78,724 KB |
testcase_17 | AC | 242 ms
79,488 KB |
testcase_18 | AC | 344 ms
79,368 KB |
testcase_19 | AC | 426 ms
79,872 KB |
testcase_20 | AC | 258 ms
79,232 KB |
testcase_21 | AC | 216 ms
79,016 KB |
testcase_22 | AC | 69 ms
68,352 KB |
testcase_23 | AC | 69 ms
68,352 KB |
testcase_24 | AC | 69 ms
68,864 KB |
testcase_25 | AC | 68 ms
68,480 KB |
testcase_26 | AC | 68 ms
68,352 KB |
testcase_27 | AC | 70 ms
68,480 KB |
testcase_28 | AC | 69 ms
68,864 KB |
testcase_29 | AC | 75 ms
68,736 KB |
testcase_30 | AC | 76 ms
68,352 KB |
testcase_31 | AC | 76 ms
68,608 KB |
testcase_32 | AC | 523 ms
80,568 KB |
testcase_33 | AC | 517 ms
80,256 KB |
testcase_34 | AC | 520 ms
80,140 KB |
testcase_35 | AC | 539 ms
80,256 KB |
testcase_36 | AC | 517 ms
80,296 KB |
testcase_37 | AC | 509 ms
80,256 KB |
testcase_38 | AC | 535 ms
79,996 KB |
testcase_39 | AC | 524 ms
80,428 KB |
testcase_40 | AC | 515 ms
80,384 KB |
testcase_41 | AC | 510 ms
80,040 KB |
testcase_42 | AC | 525 ms
80,044 KB |
testcase_43 | AC | 469 ms
79,900 KB |
testcase_44 | AC | 472 ms
79,884 KB |
testcase_45 | AC | 457 ms
80,280 KB |
testcase_46 | AC | 454 ms
80,332 KB |
testcase_47 | AC | 456 ms
80,128 KB |
testcase_48 | AC | 450 ms
80,216 KB |
testcase_49 | AC | 436 ms
80,128 KB |
ソースコード
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log from math import sqrt, ceil from bisect import bisect_left, bisect_right from typing import Iterable input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = x while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res mod = 998244353 N = int(input()) S = input() S = S[::-1] res = 0 for k in range(N): dp = [0] * (N+1) imos = [0] * (N+1) dp[0] = 1 if k+1 <= N and S[k]=="1": imos[k+1] -= dp[0] imos[k+1] %= mod SUM = dp[0] for i in range(1,N+1): imos[i] += imos[i-1] imos[i] %= mod dp[i] = (SUM + imos[i]) dp[i] %= mod SUM = (SUM+dp[i]) % mod if i+k+1 <= N and S[i+k]=="1": imos[i+k+1] -= dp[i] imos[i+k+1] %= mod res += (pow(2,N-1,mod)-dp[N]) * pow(2,k,mod) res %= mod print(res)