結果

問題 No.2592 おでぶなおばけさん 2
ユーザー rlangevinrlangevin
提出日時 2023-12-20 22:43:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 952 ms / 2,500 ms
コード長 2,566 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 108,444 KB
最終ジャッジ日時 2023-12-20 22:44:25
合計ジャッジ時間 62,710 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 262 ms
88,500 KB
testcase_02 AC 361 ms
85,608 KB
testcase_03 AC 224 ms
79,964 KB
testcase_04 AC 239 ms
79,224 KB
testcase_05 AC 484 ms
100,868 KB
testcase_06 AC 394 ms
87,132 KB
testcase_07 AC 511 ms
86,924 KB
testcase_08 AC 416 ms
90,536 KB
testcase_09 AC 250 ms
82,540 KB
testcase_10 AC 310 ms
78,528 KB
testcase_11 AC 435 ms
91,096 KB
testcase_12 AC 218 ms
80,924 KB
testcase_13 AC 626 ms
91,976 KB
testcase_14 AC 634 ms
92,268 KB
testcase_15 AC 574 ms
88,356 KB
testcase_16 AC 628 ms
91,996 KB
testcase_17 AC 674 ms
97,096 KB
testcase_18 AC 579 ms
88,372 KB
testcase_19 AC 527 ms
84,024 KB
testcase_20 AC 839 ms
88,772 KB
testcase_21 AC 766 ms
85,148 KB
testcase_22 AC 952 ms
96,376 KB
testcase_23 AC 712 ms
101,576 KB
testcase_24 AC 587 ms
89,976 KB
testcase_25 AC 490 ms
82,908 KB
testcase_26 AC 485 ms
83,100 KB
testcase_27 AC 803 ms
107,492 KB
testcase_28 AC 760 ms
107,364 KB
testcase_29 AC 784 ms
107,644 KB
testcase_30 AC 811 ms
107,772 KB
testcase_31 AC 766 ms
107,660 KB
testcase_32 AC 784 ms
107,916 KB
testcase_33 AC 778 ms
107,788 KB
testcase_34 AC 740 ms
108,316 KB
testcase_35 AC 770 ms
108,056 KB
testcase_36 AC 771 ms
107,932 KB
testcase_37 AC 762 ms
107,932 KB
testcase_38 AC 764 ms
107,932 KB
testcase_39 AC 732 ms
107,932 KB
testcase_40 AC 765 ms
108,060 KB
testcase_41 AC 726 ms
108,052 KB
testcase_42 AC 756 ms
107,928 KB
testcase_43 AC 808 ms
108,060 KB
testcase_44 AC 760 ms
108,064 KB
testcase_45 AC 785 ms
107,928 KB
testcase_46 AC 776 ms
108,060 KB
testcase_47 AC 754 ms
101,992 KB
testcase_48 AC 765 ms
101,996 KB
testcase_49 AC 764 ms
102,120 KB
testcase_50 AC 772 ms
101,996 KB
testcase_51 AC 777 ms
101,992 KB
testcase_52 AC 717 ms
107,420 KB
testcase_53 AC 745 ms
107,420 KB
testcase_54 AC 726 ms
107,424 KB
testcase_55 AC 742 ms
107,288 KB
testcase_56 AC 725 ms
107,288 KB
testcase_57 AC 357 ms
100,068 KB
testcase_58 AC 773 ms
107,236 KB
testcase_59 AC 778 ms
107,236 KB
testcase_60 AC 786 ms
107,492 KB
testcase_61 AC 745 ms
107,876 KB
testcase_62 AC 764 ms
107,492 KB
testcase_63 AC 747 ms
101,484 KB
testcase_64 AC 797 ms
107,620 KB
testcase_65 AC 796 ms
107,424 KB
testcase_66 AC 770 ms
107,424 KB
testcase_67 AC 787 ms
101,356 KB
testcase_68 AC 752 ms
107,812 KB
testcase_69 AC 776 ms
101,476 KB
testcase_70 AC 792 ms
107,552 KB
testcase_71 AC 763 ms
107,684 KB
testcase_72 AC 791 ms
107,300 KB
testcase_73 AC 758 ms
107,424 KB
testcase_74 AC 44 ms
61,968 KB
testcase_75 AC 763 ms
108,056 KB
testcase_76 AC 776 ms
108,444 KB
testcase_77 AC 746 ms
108,444 KB
testcase_78 AC 795 ms
108,056 KB
testcase_79 AC 824 ms
108,188 KB
testcase_80 AC 765 ms
108,056 KB
testcase_81 AC 784 ms
107,932 KB
testcase_82 AC 771 ms
108,184 KB
testcase_83 AC 767 ms
108,440 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 = 1 << 31 + 1
mod3 = 1 << 31 - 1
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] or T2.fold(l, r)[0] or T3.fold(l, r)[0]:
        print("Yes")
    else:
        print("No")
0