結果

問題 No.1167 Graduation Trip
ユーザー 👑 kmjpkmjp
提出日時 2020-08-14 00:57:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,978 bytes
コンパイル時間 2,963 ms
コンパイル使用メモリ 205,128 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-18 01:58:50
合計ジャッジ時間 52,135 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 3,321 ms
5,760 KB
testcase_02 AC 2,260 ms
6,016 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 3,423 ms
5,888 KB
testcase_06 TLE -
testcase_07 AC 3,236 ms
6,948 KB
testcase_08 AC 2,373 ms
6,016 KB
testcase_09 AC 3,900 ms
5,888 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
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 #

#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> l,vector<ll> r){
		vector<ll> V;
		FORR(c,l) V.push_back(c);
		FORR(c,r) V.push_back(c);
		int i,j;
		int N=V.size();
		FOR(i,N) {
			int x=max_element(V.begin()+i,V.end())-V.begin();
			if(V[x]==0) break;
			swap(V[i],V[x]);
			ll msb=1;
			while(msb<<1 <= V[i]) msb<<=1;
			FOR(j,N) if(j!=i) if(V[j]&msb) V[j]^=V[i];
		}
		int rank=N-count(V.begin(),V.end(),0);
		V.resize(rank);
		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