結果

問題 No.1167 Graduation Trip
ユーザー chineristACchineristAC
提出日時 2020-08-13 02:45:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,540 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 91,960 KB
最終ジャッジ日時 2024-04-18 01:04:22
合計ジャッジ時間 54,810 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,990 ms
90,388 KB
testcase_01 AC 2,351 ms
83,876 KB
testcase_02 AC 1,691 ms
83,396 KB
testcase_03 AC 3,005 ms
83,644 KB
testcase_04 TLE -
testcase_05 AC 3,110 ms
83,488 KB
testcase_06 AC 3,016 ms
83,548 KB
testcase_07 AC 2,099 ms
83,384 KB
testcase_08 AC 2,300 ms
83,824 KB
testcase_09 AC 2,619 ms
83,252 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#####segfunc#####
def segfunc(x, y):
    new_base=[x[i] for i in range(len(x))]
    for c in y:
        for b in new_base:
            c=min(c,c^b)
        if c:
            new_base.append(c)
    return new_base

#################

#####ide_ele#####
ide_ele = []
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return len(res)

debug=False

import sys

input=sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(lambda x:[int(x)],input().split()))
base_seg=SegTree(A,segfunc,ide_ele)
mod=10**9+7
for _ in range(Q):
    m=int(input())
    b=[-1]+list(map(lambda x:int(x)-1,input().split()))+[N-1]
    ans=1
    for i in range(1,m+2):
        L=b[i-1]+1
        R=b[i]+1
        base=base_seg.query(L,R)
        cnt=R-L
        ans*=pow(2,cnt-base,mod)
        ans%=mod
    print(ans)
    if debug:
        print("ANS:{}".format(ans))
0