結果

問題 No.2592 おでぶなおばけさん 2
ユーザー rlangevinrlangevin
提出日時 2023-12-20 22:38:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,566 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 109,888 KB
最終ジャッジ日時 2024-09-27 10:09:28
合計ジャッジ時間 87,906 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,464 KB
testcase_01 AC 331 ms
90,492 KB
testcase_02 AC 517 ms
85,788 KB
testcase_03 AC 300 ms
81,116 KB
testcase_04 AC 335 ms
80,212 KB
testcase_05 AC 627 ms
101,680 KB
testcase_06 AC 487 ms
88,892 KB
testcase_07 AC 607 ms
87,752 KB
testcase_08 AC 495 ms
91,356 KB
testcase_09 AC 291 ms
84,540 KB
testcase_10 AC 375 ms
79,972 KB
testcase_11 AC 492 ms
91,904 KB
testcase_12 AC 246 ms
81,848 KB
testcase_13 AC 1,028 ms
92,892 KB
testcase_14 AC 1,037 ms
92,908 KB
testcase_15 AC 865 ms
88,632 KB
testcase_16 AC 992 ms
92,896 KB
testcase_17 AC 1,043 ms
98,404 KB
testcase_18 AC 892 ms
89,144 KB
testcase_19 AC 807 ms
84,948 KB
testcase_20 AC 603 ms
88,796 KB
testcase_21 AC 504 ms
83,604 KB
testcase_22 AC 646 ms
96,732 KB
testcase_23 AC 1,086 ms
103,264 KB
testcase_24 AC 963 ms
91,216 KB
testcase_25 AC 749 ms
83,720 KB
testcase_26 AC 755 ms
84,008 KB
testcase_27 AC 1,156 ms
108,800 KB
testcase_28 AC 1,146 ms
109,056 KB
testcase_29 AC 1,179 ms
108,960 KB
testcase_30 AC 1,209 ms
108,604 KB
testcase_31 AC 1,187 ms
108,600 KB
testcase_32 AC 1,183 ms
108,704 KB
testcase_33 AC 1,186 ms
108,976 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1,231 ms
109,496 KB
testcase_37 AC 1,176 ms
108,912 KB
testcase_38 AC 1,174 ms
109,508 KB
testcase_39 AC 1,197 ms
109,888 KB
testcase_40 AC 1,208 ms
109,632 KB
testcase_41 AC 1,207 ms
109,244 KB
testcase_42 AC 1,185 ms
109,732 KB
testcase_43 AC 1,208 ms
109,232 KB
testcase_44 AC 1,215 ms
109,248 KB
testcase_45 AC 1,207 ms
109,216 KB
testcase_46 AC 1,223 ms
109,612 KB
testcase_47 AC 1,170 ms
102,520 KB
testcase_48 AC 1,184 ms
102,420 KB
testcase_49 AC 1,173 ms
102,904 KB
testcase_50 AC 1,195 ms
102,404 KB
testcase_51 AC 1,200 ms
102,424 KB
testcase_52 AC 1,096 ms
108,712 KB
testcase_53 AC 1,086 ms
108,872 KB
testcase_54 AC 1,106 ms
108,716 KB
testcase_55 AC 1,082 ms
108,712 KB
testcase_56 AC 1,101 ms
108,856 KB
testcase_57 AC 333 ms
100,080 KB
testcase_58 AC 1,209 ms
109,040 KB
testcase_59 AC 1,228 ms
109,068 KB
testcase_60 AC 1,210 ms
108,872 KB
testcase_61 AC 1,184 ms
108,652 KB
testcase_62 AC 1,208 ms
108,940 KB
testcase_63 AC 1,156 ms
102,280 KB
testcase_64 AC 1,173 ms
108,940 KB
testcase_65 AC 1,205 ms
108,868 KB
testcase_66 AC 1,216 ms
108,692 KB
testcase_67 AC 1,251 ms
102,804 KB
testcase_68 AC 1,225 ms
109,124 KB
testcase_69 AC 1,150 ms
102,368 KB
testcase_70 AC 1,231 ms
109,260 KB
testcase_71 AC 1,184 ms
109,112 KB
testcase_72 AC 1,234 ms
108,996 KB
testcase_73 AC 1,209 ms
109,248 KB
testcase_74 WA -
testcase_75 AC 1,190 ms
108,728 KB
testcase_76 AC 1,221 ms
109,368 KB
testcase_77 AC 1,177 ms
108,972 KB
testcase_78 AC 1,167 ms
108,896 KB
testcase_79 AC 1,188 ms
108,868 KB
testcase_80 AC 1,236 ms
109,256 KB
testcase_81 AC 1,215 ms
109,100 KB
testcase_82 AC 1,195 ms
108,856 KB
testcase_83 AC 1,211 ms
108,740 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