結果

問題 No.2592 おでぶなおばけさん 2
ユーザー rlangevinrlangevin
提出日時 2023-12-20 22:38:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,566 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 109,340 KB
最終ジャッジ日時 2023-12-20 22:40:15
合計ジャッジ時間 88,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 334 ms
89,792 KB
testcase_02 AC 501 ms
85,404 KB
testcase_03 AC 321 ms
80,744 KB
testcase_04 AC 342 ms
79,808 KB
testcase_05 AC 602 ms
101,256 KB
testcase_06 AC 478 ms
88,260 KB
testcase_07 AC 646 ms
87,288 KB
testcase_08 AC 500 ms
90,924 KB
testcase_09 AC 282 ms
83,896 KB
testcase_10 AC 373 ms
79,432 KB
testcase_11 AC 487 ms
91,484 KB
testcase_12 AC 238 ms
81,344 KB
testcase_13 AC 997 ms
92,620 KB
testcase_14 AC 958 ms
92,652 KB
testcase_15 AC 866 ms
88,224 KB
testcase_16 AC 945 ms
92,120 KB
testcase_17 AC 1,024 ms
98,248 KB
testcase_18 AC 858 ms
88,244 KB
testcase_19 AC 821 ms
84,664 KB
testcase_20 AC 562 ms
88,240 KB
testcase_21 AC 510 ms
83,320 KB
testcase_22 AC 655 ms
96,348 KB
testcase_23 AC 1,111 ms
102,728 KB
testcase_24 AC 964 ms
90,744 KB
testcase_25 AC 759 ms
83,172 KB
testcase_26 AC 740 ms
83,056 KB
testcase_27 AC 1,198 ms
108,260 KB
testcase_28 AC 1,172 ms
108,644 KB
testcase_29 AC 1,166 ms
108,540 KB
testcase_30 AC 1,211 ms
108,028 KB
testcase_31 AC 1,211 ms
108,044 KB
testcase_32 AC 1,203 ms
108,172 KB
testcase_33 AC 1,187 ms
108,428 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1,200 ms
108,704 KB
testcase_37 AC 1,133 ms
108,316 KB
testcase_38 AC 1,193 ms
109,212 KB
testcase_39 AC 1,170 ms
109,216 KB
testcase_40 AC 1,157 ms
109,340 KB
testcase_41 AC 1,186 ms
108,948 KB
testcase_42 AC 1,152 ms
108,824 KB
testcase_43 AC 1,175 ms
108,576 KB
testcase_44 AC 1,187 ms
108,828 KB
testcase_45 AC 1,141 ms
108,828 KB
testcase_46 AC 1,158 ms
108,828 KB
testcase_47 AC 1,134 ms
101,992 KB
testcase_48 AC 1,128 ms
101,992 KB
testcase_49 AC 1,147 ms
101,996 KB
testcase_50 AC 1,144 ms
101,996 KB
testcase_51 AC 1,158 ms
101,992 KB
testcase_52 AC 1,011 ms
108,188 KB
testcase_53 AC 1,007 ms
108,320 KB
testcase_54 AC 1,088 ms
108,320 KB
testcase_55 AC 1,038 ms
108,188 KB
testcase_56 AC 1,076 ms
108,316 KB
testcase_57 AC 320 ms
99,300 KB
testcase_58 AC 1,192 ms
108,260 KB
testcase_59 AC 1,203 ms
108,132 KB
testcase_60 AC 1,200 ms
108,264 KB
testcase_61 AC 1,199 ms
108,260 KB
testcase_62 AC 1,208 ms
108,132 KB
testcase_63 AC 1,132 ms
101,996 KB
testcase_64 AC 1,167 ms
108,516 KB
testcase_65 AC 1,164 ms
108,448 KB
testcase_66 AC 1,136 ms
108,452 KB
testcase_67 AC 1,126 ms
102,248 KB
testcase_68 AC 1,157 ms
108,452 KB
testcase_69 AC 1,143 ms
101,996 KB
testcase_70 AC 1,157 ms
108,580 KB
testcase_71 AC 1,146 ms
108,584 KB
testcase_72 AC 1,182 ms
108,452 KB
testcase_73 AC 1,165 ms
108,448 KB
testcase_74 WA -
testcase_75 AC 1,138 ms
108,052 KB
testcase_76 AC 1,145 ms
108,832 KB
testcase_77 AC 1,126 ms
108,316 KB
testcase_78 AC 1,120 ms
108,316 KB
testcase_79 AC 1,151 ms
108,316 KB
testcase_80 AC 1,165 ms
108,696 KB
testcase_81 AC 1,165 ms
108,828 KB
testcase_82 AC 1,190 ms
108,824 KB
testcase_83 AC 1,177 ms
108,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmentTree:
    def __init__(self,
                 n,
                 identity_e,
                 combine_f,
                 ):
        self._n = n
        self._size = 1
        while self._size < self._n:
            self._size <<= 1
        self._identity_e = identity_e
        self._combine_f = combine_f
        self._node = [self._identity_e] * (2 * self._size)
        
    def build(self, array):
        assert len(array) == self._n
        for index, value in enumerate(array, start=self._size):
            self._node[index] = value
        for index in range(self._size - 1, 0, -1):
            self._node[index] = self._combine_f(
                self._node[index << 1 | 0],
                self._node[index << 1 | 1]
            )
            
    def update(self, index, value):
        i = self._size + index
        self._node[i] = value
        while i > 1:
            i >>= 1
            self._node[i] = self._combine_f(
                self._node[i << 1 | 0],
                self._node[i << 1 | 1]
            )
            
    def fold(self, L, R):
        L += self._size
        R += self._size
        value_L = self._identity_e
        value_R = self._identity_e
        while L < R:
            if L & 1:
                value_L = self._combine_f(value_L, self._node[L])
                L += 1
            if R & 1:
                R -= 1
                value_R = self._combine_f(self._node[R], value_R)
            L >>= 1
            R >>= 1
        
        return self._combine_f(value_L, value_R)
            
            
N, Q, K = map(int, input().split())
A = list(map(int, input().split()))

mod1 = 10 ** 9 + 9
mod2 = 10 ** 9 + 7
mod3 = 998244353
p1 = [1] * (N + 1)
p2 = [1] * (N + 1)
p3 = [1] * (N + 1)
for i in range(N):
    p1[i + 1] = p1[i] * K % mod1
    p2[i + 1] = p2[i] * K % mod2
    p3[i + 1] = p3[i] * K % mod3

def op1(x, y):
    a = (x[0] + y[0] * p1[x[1]]) % mod1
    b = x[1] + y[1]
    return (a, b)

def op2(x, y):
    a = (x[0] + y[0] * p2[x[1]]) % mod2
    b = x[1] + y[1]
    return (a, b)

def op3(x, y):
    a = (x[0] + y[0] * p3[x[1]]) % mod3
    b = x[1] + y[1]
    return (a, b)
    
T1 = SegmentTree(N, (0, 0), op1)
T2 = SegmentTree(N, (0, 0), op2)
T3 = SegmentTree(N, (0, 0), op3)
for i in range(N):
    T1.update(i, (A[i]%mod1, 1))
    T2.update(i, (A[i]%mod2, 1))
    T3.update(i, (A[i]%mod3, 1))
    
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    if T1.fold(l, r)[0] and T2.fold(l, r)[0] and T3.fold(l, r)[0]:
        print("Yes")
    else:
        print("No")
0