結果

問題 No.1142 XOR と XOR
ユーザー motmot
提出日時 2020-08-01 02:41:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,269 ms / 2,000 ms
コード長 1,445 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 88,532 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:35:12
合計ジャッジ時間 20,209 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1,269 ms
6,944 KB
testcase_04 AC 976 ms
6,940 KB
testcase_05 AC 800 ms
6,944 KB
testcase_06 AC 1,016 ms
6,940 KB
testcase_07 AC 1,231 ms
6,940 KB
testcase_08 AC 1,249 ms
6,940 KB
testcase_09 AC 1,248 ms
6,944 KB
testcase_10 AC 1,250 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 686 ms
6,944 KB
testcase_15 AC 656 ms
6,944 KB
testcase_16 AC 52 ms
6,940 KB
testcase_17 AC 935 ms
6,940 KB
testcase_18 AC 213 ms
6,944 KB
testcase_19 AC 1,012 ms
6,940 KB
testcase_20 AC 629 ms
6,940 KB
testcase_21 AC 418 ms
6,944 KB
testcase_22 AC 223 ms
6,940 KB
testcase_23 AC 944 ms
6,940 KB
testcase_24 AC 1,065 ms
6,944 KB
testcase_25 AC 640 ms
6,944 KB
testcase_26 AC 1,015 ms
6,940 KB
testcase_27 AC 822 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll DP1[1024], DP2[1024];

int main() {
  int N, M, K;
  cin>>N>>M>>K;
  int a[N], b[M];
  for(int i=0;i<N;++i) cin>>a[i];
  for(int i=0;i<M;++i) cin>>b[i];
  vector<ll> befarr(1024), aftarr(1024);
  for(int i=0;i<1024;++i) {
    befarr[i] = 0;
    aftarr[i] = 0;
  }
  for(int i=0;i<N;++i) {
    befarr[0]++;
    for(int j=0;j<(1<<10);++j) {
      aftarr[j^a[i]] += befarr[j];
    }
    for(int j=0;j<(1<<10);++j) {
      DP1[j] += aftarr[j];
      DP1[j] %= mod;
    }
    befarr = aftarr;
    for(int j=0;j<(1<<10);++j) aftarr[j] = 0;
  }
  for(int i=0;i<(1<<10);++i) befarr[i] = 0;
  for(int i=0;i<M;++i) {
    befarr[0]++;
    for(int j=0;j<(1<<10);++j) {
      aftarr[j^b[i]] += befarr[j];
    }
    for(int j=0;j<(1<<10);++j) {
      DP2[j] += aftarr[j];
      DP2[j] %= mod;
    }
    befarr = aftarr;
    for(int j=0;j<(1<<10);++j) aftarr[j] = 0;
  }
  ll ans = 0;
  for(int i=0;i<(1<<10);++i) {
    ans += DP1[i]*DP2[K^i]%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}

0