CODE THANKS FESTIVAL 2017

Submission #1822207

Source codeソースコード

// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

const int S = 100010;
int a[S], mbit[S];
int dp[2][S];

signed main() {
    int N, K; cin >> N >> K;
    rep(i,0,N) {
        cin >> a[i];
    }
    sort(a, a+N);
    rep(i,0,N) {
        int p = a[i], tmp = 0;
        while(p) {
            tmp++;
            p >>= 1LL;
        }
        mbit[i] = tmp;
        // printf("mbit[%lld] = %lld\n", i, tmp);
    }

    dp[0][0] = 1;
    rep(i,0,N) {
        int mo = i % 2;
        rep(bit,0,1LL<<mbit[i]) {
            // do not use
            (dp[mo^1][bit] += dp[mo][bit]) %= MOD;

            // use
            (dp[mo^1][bit ^ a[i]] += dp[mo][bit]) %= MOD;
        }
        // rep(k,0,1LL<<(mbit[i])) printf("dp[%lld][%lld] = %lld\n", i+1, k, dp[mo^1][k]);
        memset(dp[mo], 0, sizeof(dp[mo]));
    }
    cout << dp[N%2][K] << endl;
    return 0;
}

Submission

Task問題 F - Limited Xor Subset
User nameユーザ名 tsutaj
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 0
Source lengthソースコード長 1914 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 500 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 2 ms 1792 KB
sample_02.txt AC 2 ms 1792 KB
sample_03.txt AC 2 ms 1792 KB
subtask_1_1.txt AC 3 ms 1792 KB
subtask_1_10.txt AC 25 ms 1792 KB
subtask_1_11.txt AC 10 ms 1792 KB
subtask_1_12.txt AC 5 ms 1792 KB
subtask_1_13.txt AC 5 ms 1792 KB
subtask_1_14.txt AC 3 ms 1792 KB
subtask_1_15.txt AC 3 ms 2048 KB
subtask_1_16.txt AC 3 ms 1792 KB
subtask_1_17.txt AC 2 ms 1792 KB
subtask_1_18.txt TLE
subtask_1_19.txt AC 1306 ms 2304 KB
subtask_1_2.txt AC 3 ms 1792 KB
subtask_1_20.txt AC 19 ms 1792 KB
subtask_1_21.txt AC 19 ms 1792 KB
subtask_1_22.txt AC 1 ms 1024 KB
subtask_1_23.txt AC 1 ms 1152 KB
subtask_1_24.txt AC 3 ms 2048 KB
subtask_1_25.txt TLE
subtask_1_26.txt AC 14 ms 1792 KB
subtask_1_27.txt AC 3 ms 2048 KB
subtask_1_28.txt AC 3 ms 1792 KB
subtask_1_29.txt AC 2 ms 1792 KB
subtask_1_3.txt AC 3 ms 1792 KB
subtask_1_30.txt AC 2 ms 1792 KB
subtask_1_4.txt AC 3 ms 1792 KB
subtask_1_5.txt AC 3 ms 1792 KB
subtask_1_6.txt AC 1513 ms 2432 KB
subtask_1_7.txt AC 448 ms 2048 KB
subtask_1_8.txt AC 78 ms 1792 KB
subtask_1_9.txt AC 32 ms 1792 KB