結果

問題 No.2592 おでぶなおばけさん 2
ユーザー rlangevinrlangevin
提出日時 2023-12-20 22:40:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,564 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,956 KB
最終ジャッジ日時 2023-12-20 22:41:08
合計ジャッジ時間 63,464 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 274 ms
88,428 KB
testcase_02 AC 360 ms
84,776 KB
testcase_03 AC 227 ms
79,976 KB
testcase_04 AC 268 ms
79,084 KB
testcase_05 AC 493 ms
101,388 KB
testcase_06 AC 413 ms
87,132 KB
testcase_07 AC 520 ms
87,004 KB
testcase_08 AC 421 ms
90,540 KB
testcase_09 AC 252 ms
82,540 KB
testcase_10 AC 334 ms
78,792 KB
testcase_11 AC 425 ms
91,616 KB
testcase_12 AC 222 ms
80,968 KB
testcase_13 AC 683 ms
91,720 KB
testcase_14 AC 644 ms
92,648 KB
testcase_15 AC 607 ms
87,840 KB
testcase_16 AC 645 ms
91,996 KB
testcase_17 AC 705 ms
96,968 KB
testcase_18 AC 576 ms
88,372 KB
testcase_19 AC 508 ms
83,892 KB
testcase_20 AC 848 ms
88,692 KB
testcase_21 AC 790 ms
83,960 KB
testcase_22 AC 997 ms
97,240 KB
testcase_23 AC 698 ms
101,576 KB
testcase_24 AC 637 ms
90,104 KB
testcase_25 AC 487 ms
83,152 KB
testcase_26 AC 496 ms
82,780 KB
testcase_27 AC 812 ms
108,260 KB
testcase_28 AC 824 ms
108,388 KB
testcase_29 AC 799 ms
108,156 KB
testcase_30 AC 814 ms
108,156 KB
testcase_31 AC 823 ms
108,300 KB
testcase_32 AC 782 ms
108,304 KB
testcase_33 AC 820 ms
108,300 KB
testcase_34 AC 817 ms
107,928 KB
testcase_35 AC 755 ms
107,544 KB
testcase_36 AC 814 ms
107,932 KB
testcase_37 AC 751 ms
108,060 KB
testcase_38 AC 752 ms
107,932 KB
testcase_39 AC 758 ms
107,932 KB
testcase_40 AC 749 ms
108,060 KB
testcase_41 AC 769 ms
107,924 KB
testcase_42 AC 768 ms
107,928 KB
testcase_43 AC 768 ms
108,952 KB
testcase_44 AC 784 ms
108,956 KB
testcase_45 AC 755 ms
108,316 KB
testcase_46 AC 790 ms
108,444 KB
testcase_47 AC 729 ms
101,612 KB
testcase_48 AC 748 ms
101,480 KB
testcase_49 AC 768 ms
101,476 KB
testcase_50 AC 727 ms
101,352 KB
testcase_51 AC 757 ms
101,484 KB
testcase_52 AC 712 ms
108,060 KB
testcase_53 AC 727 ms
108,188 KB
testcase_54 AC 726 ms
108,068 KB
testcase_55 AC 709 ms
108,056 KB
testcase_56 AC 736 ms
108,696 KB
testcase_57 AC 323 ms
99,304 KB
testcase_58 AC 807 ms
108,516 KB
testcase_59 AC 773 ms
108,260 KB
testcase_60 AC 794 ms
108,388 KB
testcase_61 AC 820 ms
108,388 KB
testcase_62 AC 789 ms
108,388 KB
testcase_63 AC 768 ms
101,480 KB
testcase_64 AC 789 ms
108,516 KB
testcase_65 AC 773 ms
107,808 KB
testcase_66 AC 794 ms
107,808 KB
testcase_67 AC 756 ms
101,484 KB
testcase_68 AC 767 ms
107,812 KB
testcase_69 AC 762 ms
101,480 KB
testcase_70 AC 778 ms
107,812 KB
testcase_71 AC 791 ms
107,944 KB
testcase_72 AC 766 ms
107,816 KB
testcase_73 AC 769 ms
107,808 KB
testcase_74 WA -
testcase_75 AC 779 ms
107,932 KB
testcase_76 AC 772 ms
108,060 KB
testcase_77 AC 765 ms
107,932 KB
testcase_78 AC 770 ms
107,928 KB
testcase_79 AC 762 ms
107,932 KB
testcase_80 AC 791 ms
108,188 KB
testcase_81 AC 772 ms
107,932 KB
testcase_82 AC 817 ms
107,928 KB
testcase_83 AC 780 ms
108,060 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] or T2.fold(l, r)[0] or T3.fold(l, r)[0]:
        print("Yes")
    else:
        print("No")
0