結果

問題 No.1167 Graduation Trip
ユーザー chineristACchineristAC
提出日時 2020-08-13 02:54:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,388 ms / 4,000 ms
コード長 1,404 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 112,384 KB
最終ジャッジ日時 2024-04-18 01:05:15
合計ジャッジ時間 43,302 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,994 ms
111,768 KB
testcase_01 AC 1,512 ms
111,360 KB
testcase_02 AC 813 ms
105,088 KB
testcase_03 AC 2,310 ms
112,144 KB
testcase_04 AC 1,575 ms
111,872 KB
testcase_05 AC 1,539 ms
111,456 KB
testcase_06 AC 1,928 ms
111,544 KB
testcase_07 AC 1,551 ms
105,856 KB
testcase_08 AC 972 ms
105,460 KB
testcase_09 AC 1,217 ms
111,488 KB
testcase_10 AC 2,328 ms
111,592 KB
testcase_11 AC 2,271 ms
112,128 KB
testcase_12 AC 1,729 ms
112,148 KB
testcase_13 AC 2,388 ms
112,384 KB
testcase_14 AC 1,935 ms
111,724 KB
testcase_15 AC 1,458 ms
111,812 KB
testcase_16 AC 1,386 ms
104,920 KB
testcase_17 AC 2,330 ms
111,880 KB
testcase_18 AC 2,150 ms
111,616 KB
testcase_19 AC 2,167 ms
111,872 KB
testcase_20 AC 110 ms
77,056 KB
testcase_21 AC 124 ms
77,336 KB
testcase_22 AC 99 ms
76,780 KB
testcase_23 AC 124 ms
76,928 KB
testcase_24 AC 115 ms
76,936 KB
testcase_25 AC 107 ms
77,192 KB
testcase_26 AC 106 ms
76,908 KB
testcase_27 AC 115 ms
76,668 KB
testcase_28 AC 123 ms
77,056 KB
testcase_29 AC 102 ms
76,556 KB
testcase_30 AC 178 ms
82,348 KB
testcase_31 AC 281 ms
90,752 KB
testcase_32 AC 315 ms
91,648 KB
testcase_33 AC 977 ms
109,284 KB
testcase_34 AC 1,210 ms
109,912 KB
testcase_35 AC 42 ms
52,352 KB
testcase_36 AC 43 ms
52,480 KB
testcase_37 AC 50 ms
59,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#####segfunc#####
def merge_func(x, y):
    new_base=[x[i] for i in range(len(x)) if x[i]!=0]
    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 SparseTable():
    def __init__(self,A,merge_func,ide_ele):
        N=len(A)
        n=N.bit_length()
        self.table=[[ide_ele for i in range(n)] for i in range(N)]
        self.merge_func=merge_func

        for i in range(N):
            self.table[i][0]=A[i]

        for j in range(1,n):
            for i in range(0,N-2**j+1):
                f=self.table[i][j-1]
                s=self.table[i+2**(j-1)][j-1]
                self.table[i][j]=self.merge_func(f,s)

    def query(self,s,t):
        b=t-s+1
        m=b.bit_length()-1
        return len(self.merge_func(self.table[s][m],self.table[t-2**m+1][m]))

debug=False

import sys

input=sys.stdin.buffer.readline

N,Q=map(int,input().split())
A=list(map(lambda x:[int(x)],input().split()))
base_seg=SparseTable(A,merge_func,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]
        base=base_seg.query(L,R)
        cnt=R-L+1
        ans*=pow(2,cnt-base,mod)
        ans%=mod
    print(ans)
    
0