結果
問題 | No.2279 OR Insertion |
ユーザー | chineristAC |
提出日時 | 2023-04-21 21:45:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 548 ms / 2,000 ms |
コード長 | 2,127 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 80,640 KB |
最終ジャッジ日時 | 2024-04-24 07:55:34 |
合計ジャッジ時間 | 17,008 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 87 ms
68,480 KB |
testcase_01 | AC | 79 ms
69,120 KB |
testcase_02 | AC | 154 ms
78,976 KB |
testcase_03 | AC | 136 ms
78,976 KB |
testcase_04 | AC | 499 ms
80,128 KB |
testcase_05 | AC | 112 ms
78,976 KB |
testcase_06 | AC | 261 ms
79,616 KB |
testcase_07 | AC | 271 ms
79,360 KB |
testcase_08 | AC | 161 ms
79,104 KB |
testcase_09 | AC | 331 ms
79,360 KB |
testcase_10 | AC | 486 ms
79,744 KB |
testcase_11 | AC | 150 ms
78,976 KB |
testcase_12 | AC | 402 ms
79,744 KB |
testcase_13 | AC | 120 ms
78,720 KB |
testcase_14 | AC | 127 ms
78,720 KB |
testcase_15 | AC | 291 ms
79,488 KB |
testcase_16 | AC | 105 ms
78,976 KB |
testcase_17 | AC | 256 ms
79,616 KB |
testcase_18 | AC | 366 ms
79,744 KB |
testcase_19 | AC | 443 ms
80,000 KB |
testcase_20 | AC | 273 ms
79,232 KB |
testcase_21 | AC | 230 ms
79,360 KB |
testcase_22 | AC | 81 ms
68,608 KB |
testcase_23 | AC | 78 ms
68,608 KB |
testcase_24 | AC | 77 ms
68,480 KB |
testcase_25 | AC | 78 ms
68,352 KB |
testcase_26 | AC | 78 ms
68,352 KB |
testcase_27 | AC | 78 ms
68,480 KB |
testcase_28 | AC | 79 ms
68,352 KB |
testcase_29 | AC | 77 ms
68,352 KB |
testcase_30 | AC | 81 ms
68,224 KB |
testcase_31 | AC | 77 ms
68,736 KB |
testcase_32 | AC | 537 ms
80,512 KB |
testcase_33 | AC | 532 ms
80,128 KB |
testcase_34 | AC | 529 ms
80,128 KB |
testcase_35 | AC | 539 ms
80,384 KB |
testcase_36 | AC | 534 ms
80,512 KB |
testcase_37 | AC | 529 ms
80,384 KB |
testcase_38 | AC | 543 ms
80,640 KB |
testcase_39 | AC | 532 ms
80,128 KB |
testcase_40 | AC | 541 ms
80,128 KB |
testcase_41 | AC | 534 ms
80,384 KB |
testcase_42 | AC | 548 ms
80,512 KB |
testcase_43 | AC | 490 ms
80,512 KB |
testcase_44 | AC | 496 ms
80,512 KB |
testcase_45 | AC | 477 ms
80,256 KB |
testcase_46 | AC | 479 ms
80,512 KB |
testcase_47 | AC | 481 ms
80,000 KB |
testcase_48 | AC | 468 ms
80,128 KB |
testcase_49 | AC | 456 ms
80,000 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)