Submission #19534042


Source Code Expand

Copy
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

class BIT {
	const int n;
	vector<Int> bit;
public:
	BIT(int _n = 0) : n(_n), bit(n + 1, 0) {}
	void add(int i, const Int x = 1) { for (i++; i <= n; i += i&-i) bit[i] += x; }
	Int sum(int i) { Int x = 0; for (i++; i; i -= i & -i) x += bit[i]; return x; }
	Int sum(int i, int j) { return sum(j) - sum(i - 1); }
};

int n, k;
int a[N];

void solve()
{
	cin >> n >> k;
	int sum = 0;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);

	int limit = 0;
	vector<Int> dp(sum + 10, 0);
	dp[0] = 1;

	REP(i, n) {
		vector<Int> dp2(sum + 10, 0);
		REP(j, limit + 1) {
			dp2[j] += dp[j];
			dp2[j] %= MOD;
			dp2[j ^ a[i]] += dp[j];
			dp2[j ^ a[i]] %= MOD;
		}
		limit |= a[i];
		REP(s, sum + 10) dp[s] = dp2[s];
	}
	cout << dp[k] << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}

Submission Info

Submission Time
Task F - Limited Xor Subset
User chuka231
Language C++ (GCC 9.2.1)
Score 0
Code Size 1767 Byte
Status TLE
Exec Time 2205 ms
Memory 5120 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 29
TLE × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_2.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_3.txt, subtask_1_30.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 6 ms 3536 KB
sample_02.txt AC 3 ms 3588 KB
sample_03.txt AC 3 ms 3544 KB
subtask_1_1.txt AC 11 ms 4616 KB
subtask_1_10.txt AC 72 ms 4752 KB
subtask_1_11.txt AC 37 ms 4616 KB
subtask_1_12.txt AC 16 ms 4608 KB
subtask_1_13.txt AC 21 ms 4604 KB
subtask_1_14.txt AC 10 ms 4700 KB
subtask_1_15.txt AC 13 ms 4756 KB
subtask_1_16.txt AC 8 ms 4616 KB
subtask_1_17.txt AC 5 ms 4680 KB
subtask_1_18.txt TLE 2205 ms 5016 KB
subtask_1_19.txt TLE 2205 ms 4868 KB
subtask_1_2.txt AC 14 ms 4700 KB
subtask_1_20.txt AC 52 ms 4672 KB
subtask_1_21.txt AC 57 ms 4616 KB
subtask_1_22.txt AC 3 ms 3536 KB
subtask_1_23.txt AC 2 ms 3652 KB
subtask_1_24.txt AC 7 ms 4616 KB
subtask_1_25.txt TLE 2205 ms 5120 KB
subtask_1_26.txt AC 45 ms 4644 KB
subtask_1_27.txt AC 4 ms 4696 KB
subtask_1_28.txt AC 5 ms 4684 KB
subtask_1_29.txt AC 5 ms 4552 KB
subtask_1_3.txt AC 9 ms 4756 KB
subtask_1_30.txt AC 5 ms 4700 KB
subtask_1_4.txt AC 7 ms 4696 KB
subtask_1_5.txt AC 8 ms 4644 KB
subtask_1_6.txt TLE 2205 ms 4980 KB
subtask_1_7.txt AC 1079 ms 4752 KB
subtask_1_8.txt AC 196 ms 4612 KB
subtask_1_9.txt AC 88 ms 4756 KB