結果

問題 No.1167 Graduation Trip
ユーザー msm1993msm1993
提出日時 2020-09-11 16:21:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 849 ms / 4,000 ms
コード長 1,718 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 208,988 KB
実行使用メモリ 5,808 KB
最終ジャッジ日時 2023-08-26 23:43:38
合計ジャッジ時間 19,638 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 544 ms
5,744 KB
testcase_01 AC 406 ms
5,704 KB
testcase_02 AC 291 ms
5,612 KB
testcase_03 AC 544 ms
5,748 KB
testcase_04 AC 543 ms
5,748 KB
testcase_05 AC 428 ms
5,620 KB
testcase_06 AC 545 ms
5,728 KB
testcase_07 AC 384 ms
5,616 KB
testcase_08 AC 309 ms
5,632 KB
testcase_09 AC 475 ms
5,740 KB
testcase_10 AC 841 ms
5,808 KB
testcase_11 AC 849 ms
5,632 KB
testcase_12 AC 839 ms
5,632 KB
testcase_13 AC 840 ms
5,724 KB
testcase_14 AC 841 ms
5,752 KB
testcase_15 AC 660 ms
5,740 KB
testcase_16 AC 477 ms
5,684 KB
testcase_17 AC 837 ms
5,696 KB
testcase_18 AC 764 ms
5,748 KB
testcase_19 AC 841 ms
5,664 KB
testcase_20 AC 24 ms
4,492 KB
testcase_21 AC 26 ms
4,400 KB
testcase_22 AC 23 ms
4,508 KB
testcase_23 AC 27 ms
4,632 KB
testcase_24 AC 26 ms
4,404 KB
testcase_25 AC 24 ms
4,696 KB
testcase_26 AC 23 ms
4,396 KB
testcase_27 AC 27 ms
4,632 KB
testcase_28 AC 27 ms
4,572 KB
testcase_29 AC 24 ms
4,572 KB
testcase_30 AC 71 ms
4,400 KB
testcase_31 AC 101 ms
5,480 KB
testcase_32 AC 108 ms
5,464 KB
testcase_33 AC 8 ms
5,624 KB
testcase_34 AC 8 ms
5,616 KB
testcase_35 AC 3 ms
4,556 KB
testcase_36 AC 3 ms
4,408 KB
testcase_37 AC 3 ms
4,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
ll A[10101];

template<int NV> class SegTree_1 {
public:
	vector<vector<ll>> val;
	vector<ll> comp(vector<ll> V,vector<ll> W){
		if(V.size()<W.size()) swap(V,W);
		FORR(w,W) {
			FORR(v,V) w=min(w,v^w);
			if(w) V.push_back(w);
		}
		return V;
	}
	
	SegTree_1(){val.resize(NV*2);};
	vector<ll> getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return {};
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void build() {
		int i;
		for(i=NV-1;i>=1;i--) val[i]=comp(val[i*2],val[i*2+1]);
	}
};
SegTree_1<1<<15> st;
ll p2[10101];
int M,B[10101];
const ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,10100) p2[i+1]=p2[i]*2%mo;
	
	cin>>N>>Q;
	FOR(i,N) {
		cin>>A[i];
		if(A[i]) st.val[(1<<15)+i].push_back(A[i]);
	}
	st.build();
	
	while(Q--) {
		cin>>M;
		FOR(i,M) cin>>B[i];
		B[M]=N;
		int num=0;
		int pre=0;
		FOR(i,M+1) {
			num+=(B[i]-pre)-st.getval(pre,B[i]).size();
			pre=B[i];
		}
		cout<<p2[num]<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0