結果

問題 No.2833 Count Taiko Results
ユーザー tassei903tassei903
提出日時 2024-08-02 23:04:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,439 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 82,616 KB
実行使用メモリ 140,332 KB
最終ジャッジ日時 2024-08-02 23:04:47
合計ジャッジ時間 13,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 35 ms
53,396 KB
testcase_02 AC 36 ms
54,348 KB
testcase_03 AC 36 ms
54,220 KB
testcase_04 AC 36 ms
53,268 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 36 ms
53,492 KB
testcase_08 AC 43 ms
60,716 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 42 ms
59,964 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 35 ms
53,820 KB
testcase_16 AC 36 ms
58,684 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 36 ms
52,592 KB
testcase_23 AC 35 ms
53,288 KB
testcase_24 AC 37 ms
54,728 KB
testcase_25 AC 36 ms
54,988 KB
testcase_26 WA -
testcase_27 AC 36 ms
54,520 KB
testcase_28 WA -
testcase_29 AC 34 ms
53,996 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 311 ms
111,860 KB
testcase_37 WA -
testcase_38 AC 241 ms
97,204 KB
testcase_39 AC 292 ms
112,396 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 368 ms
139,668 KB
testcase_53 WA -
testcase_54 AC 33 ms
52,772 KB
testcase_55 AC 272 ms
139,616 KB
testcase_56 AC 277 ms
139,572 KB
testcase_57 AC 276 ms
139,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
inf = 10**18
class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : min(x,y), default=inf):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f
 
    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])
    def updatef(self, i, x):
        i += self.size
        self.dat[i] = self.f(self.dat[i],x)
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])
 
    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1
 
            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res
 
    def query2(self):
        s = 1
        #print(self.size)
        while s<self.size:
            #print(s)
            if self.dat[s*2]>self.dat[s*2+1]:
                s = s*2
            else:
                s = s*2+1
        return s-self.size

mod = 998244353
n,k = na()
a = na()
b = na()

st1 = SegmentTree(n+1,lambda x,y : x*y%mod,1)
st2 = SegmentTree(n+1,lambda x,y : x*y%mod,1)
for i in range(n):
    st1.update(i,a[i])
    st2.update(i,b[i] + a[i])
ans = 0
for i in range(n-k+1):
    z = 1
    z *= st1.query(i,i+k)
    z %= mod
    if i:
        z *= b[i-1]
        z %= mod
        z *= st2.query(0,i-1)
    if i + k < n:
        z *= b[i+k]
        z %= mod
        z *= st2.query(i+k+1,n)
        z %= mod
    ans += z
    ans %= mod 
print(ans)
0