結果

問題 No.1167 Graduation Trip
ユーザー chocoruskchocorusk
提出日時 2020-08-12 01:48:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,316 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 145,448 KB
実行使用メモリ 12,836 KB
最終ジャッジ日時 2024-04-17 18:17:35
合計ジャッジ時間 42,505 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,938 ms
6,812 KB
testcase_01 AC 2,360 ms
6,940 KB
testcase_02 AC 1,823 ms
6,944 KB
testcase_03 AC 2,944 ms
6,944 KB
testcase_04 AC 2,915 ms
6,940 KB
testcase_05 AC 2,462 ms
6,944 KB
testcase_06 AC 2,939 ms
6,940 KB
testcase_07 AC 2,291 ms
6,940 KB
testcase_08 AC 1,934 ms
6,940 KB
testcase_09 AC 2,661 ms
6,944 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 3,895 ms
6,940 KB
testcase_16 AC 3,058 ms
6,944 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 25 ms
6,940 KB
testcase_21 AC 29 ms
6,948 KB
testcase_22 AC 23 ms
6,944 KB
testcase_23 AC 29 ms
6,944 KB
testcase_24 AC 29 ms
6,948 KB
testcase_25 AC 23 ms
6,944 KB
testcase_26 AC 23 ms
6,944 KB
testcase_27 AC 29 ms
6,944 KB
testcase_28 AC 28 ms
6,944 KB
testcase_29 AC 24 ms
6,944 KB
testcase_30 AC 77 ms
6,944 KB
testcase_31 AC 330 ms
6,940 KB
testcase_32 AC 448 ms
6,948 KB
testcase_33 AC 18 ms
6,944 KB
testcase_34 AC 17 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 1 ms
6,948 KB
testcase_37 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
using uint=unsigned int;
uint a[10010];
vector<int> Gauss_Jordan(vector<int> &v){ //v[i]<2^MAX
    int n=v.size();
    vector<uint> w(n);
    for(int i=0; i<n; i++) w[i]=a[v[i]];
    vector<bool> b(n);
    for(int i=0; i<32; i++){
        int p=-1;
        for(int j=0; j<n; j++){
            if(b[j]) continue;
            if((w[j]>>i)&1){
                b[j]=1;
                p=j;
                break;
            }
        }
        if(p==-1) continue;
        for(int j=p+1; j<n; j++){
            if((w[j]>>i)&1){
                w[j]^=w[p];
            }
        }
    }
    vector<int> ret;
    for(int j=0; j<n; j++){
        if(b[j]) ret.push_back(v[j]);
    }
    return ret;
}
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	/*Monoid query(int a, int b){ //演算が非可換のとき
		a+=sz, b+=sz;
		Monoid retl=e, retr=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) retr=f(seg[--b], retr);
			if(a&1) retl=f(retl, seg[a++]);
		}
		return f(retl, retr);
	}*/

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
int main()
{
    int n, q;
    cin>>n>>q;
    for(int i=0; i<n; i++) cin>>a[i];
    auto f=[&](vector<int> v, vector<int> w){
        v.insert(v.end(), w.begin(), w.end());
        return Gauss_Jordan(v);
    };
    vector<vector<int>> va(n);
    for(int i=0; i<n; i++) if(a[i]>0) va[i].push_back(i);
    vector<int> e;
    SegmentTree<vector<int>> seg(n, f, e, va);
    while(q--){
        int m; cin>>m;
        int pr=0;
        int sum=0;
        for(int i=0; i<m; i++){
            int b; cin>>b;
            int r=seg.query(pr, b).size();
            sum+=b-pr-r;
            pr=b;
        }
        sum+=n-pr-(int)seg.query(pr, n).size();
        cout<<powmod(2, sum)<<endl;
    }
    return 0;
}
0