結果

問題 No.1142 XOR と XOR
コンテスト
ユーザー ひばち
提出日時 2020-07-31 22:43:33
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 850 ms / 2,000 ms
コード長 1,286 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,292 ms
コンパイル使用メモリ 212,788 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-11 21:45:12
合計ジャッジ時間 12,385 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rrep(i, N) for (int i = (int)(N)-1; i >= 0; --i)
#define debug(x) cout << #x << "=" << x << endl;
constexpr int MOD=1000000007;
constexpr ll INF = (1LL << 61) - 1;
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;} return false;}
template <typename T> void fail(T v){cout << v << endl;exit(0);}
//template

void solve(){
    int N,M,K;scanf("%d %d %d",&N,&M,&K);
    int A[201010],B[201010],S[201010],ct[1<<10];ll D[1<<10];
    memset(ct,0,sizeof(ct));
    memset(D,0,sizeof(D));
    S[0]=0;
    rep(i,N){scanf("%d",&A[i]);S[i+1]=S[i]^A[i];ct[S[i+1]]++;}
    rep(i,N){
        rep(j,1<<10){D[j^S[i]]+=ct[j];}
        ct[S[i+1]]--;
    }
    memset(ct,0,sizeof(ct));
    rep(i,M){scanf("%d",&B[i]);S[i+1]=S[i]^B[i];ct[S[i+1]]++;}
    ll res=0;
    rep(i,M){
        rep(j,1<<10){res+=D[j^S[i]^K]*ct[j];if(res>=MOD)res%=MOD;}
        ct[S[i+1]]--;
    }
    cout<<res<<endl;
}

int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    solve();
    return 0;
}
0