結果

問題 No.1142 XOR と XOR
ユーザー face4
提出日時 2020-08-10 11:54:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 889 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 64,896 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 03:47:39
合計ジャッジ時間 14,425 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

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];
    int acca[1<<10] = {}, accb[1<<10] = {}, ax[1<<10] = {}, bx[1<<10] = {};
    int tmp = 0;
    acca[0] = accb[0] = 1;
    for(int i = 0; i < n; i++){
        tmp ^= a[i];
        for(int j = 0; j < 1<<10; j++){
            ax[j^tmp] += acca[j];
            ax[j^tmp] %= mod;
        }
        acca[tmp]++;
    }
    tmp = 0;
    for(int i = 0; i < m; i++){
        tmp ^= b[i];
        for(int j = 0; j < 1<<10; j++){
            bx[j^tmp] += accb[j];
            bx[j^tmp] %= mod;
        }
        accb[tmp]++;
    }
    ll ans = 0;
    for(int i = 0; i < 1<<10; i++){
        ans += (ll)(ax[i]) * bx[k^i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0