結果

問題 No.1167 Graduation Trip
ユーザー 沙耶花沙耶花
提出日時 2021-04-07 15:57:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,352 ms / 4,000 ms
コード長 1,565 bytes
コンパイル時間 5,641 ms
コンパイル使用メモリ 268,060 KB
実行使用メモリ 5,548 KB
最終ジャッジ日時 2023-09-04 18:16:15
合計ジャッジ時間 45,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,467 ms
5,472 KB
testcase_01 AC 1,069 ms
5,476 KB
testcase_02 AC 779 ms
5,420 KB
testcase_03 AC 1,462 ms
5,476 KB
testcase_04 AC 1,450 ms
5,412 KB
testcase_05 AC 1,145 ms
5,540 KB
testcase_06 AC 1,471 ms
5,448 KB
testcase_07 AC 1,030 ms
5,400 KB
testcase_08 AC 823 ms
5,412 KB
testcase_09 AC 1,263 ms
5,404 KB
testcase_10 AC 2,346 ms
5,468 KB
testcase_11 AC 2,335 ms
5,408 KB
testcase_12 AC 2,352 ms
5,472 KB
testcase_13 AC 2,345 ms
5,412 KB
testcase_14 AC 2,345 ms
5,464 KB
testcase_15 AC 1,830 ms
5,432 KB
testcase_16 AC 1,342 ms
5,472 KB
testcase_17 AC 2,342 ms
5,424 KB
testcase_18 AC 2,129 ms
5,472 KB
testcase_19 AC 2,349 ms
5,532 KB
testcase_20 AC 28 ms
4,376 KB
testcase_21 AC 31 ms
4,380 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 32 ms
4,376 KB
testcase_24 AC 31 ms
4,376 KB
testcase_25 AC 26 ms
4,380 KB
testcase_26 AC 26 ms
4,380 KB
testcase_27 AC 31 ms
4,380 KB
testcase_28 AC 31 ms
4,376 KB
testcase_29 AC 25 ms
4,376 KB
testcase_30 AC 152 ms
5,032 KB
testcase_31 AC 253 ms
4,948 KB
testcase_32 AC 332 ms
5,208 KB
testcase_33 AC 14 ms
5,424 KB
testcase_34 AC 14 ms
5,548 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000

void Func(vector<long long> &A){
	int last = 0;
	for(long long i=31;i>=0;i--){
		int ind = -1;
		for(int j=last;j<A.size();j++){
			if((A[j]>>i) & 1LL){
				ind = j;
				break;
				swap(A[j],A[last]);
				ind = last;
				last++;
				break;
			}
		}
		if(ind==-1)continue;
		for(int j=0;j<A.size();j++){
			if(j!=ind){
				if((A[j]>>i)&1LL){
					A[j] ^= A[ind];
				}
			}
		}
		swap(A[last],A[ind]);
		last++;
	}
	while(A.size()!=0&&A.back()==0)A.pop_back();
	return;
}

vector<long long> op(vector<long long> A,vector<long long> B){
	while(B.size()>0){
		A.push_back(B.back());
		B.pop_back();
	}
	Func(A);
	return A;
}

vector<long long> e(){
	return vector<long long>(0);
}

int beki(long long a,long long b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<vector<long long>> A(N);
	for(int i=0;i<N;i++){
		long long t;
		cin>>t;
		A[i] = {t};
	}
	
	segtree<vector<long long>,op,e> S(A);
	
	for(int i=0;i<Q;i++){
		int M;
		cin>>M;
		
		vector<int> B(M);
		for(int j=0;j<M;j++)cin>>B[j];
		int ans = 1;
		for(int j=0;j<=M;j++){
			int l,r;
			if(j!=0)l = B[j-1];
			else l=0;
			if(j!=M)r = B[j];
			else r=N;
			
			int t = S.prod(l,r).size();
			ans = mod(ans * beki(2,r-l-t));
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}
0