結果

問題 No.1142 XOR と XOR
ユーザー 小指が強い人小指が強い人
提出日時 2020-08-11 00:04:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 2,944 bytes
コンパイル時間 2,489 ms
コンパイル使用メモリ 207,672 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:41:16
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 5 ms
6,940 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 106 ms
6,944 KB
testcase_04 AC 72 ms
6,944 KB
testcase_05 AC 61 ms
6,944 KB
testcase_06 AC 74 ms
6,944 KB
testcase_07 AC 65 ms
6,944 KB
testcase_08 AC 91 ms
6,944 KB
testcase_09 AC 91 ms
6,940 KB
testcase_10 AC 91 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 50 ms
6,940 KB
testcase_15 AC 49 ms
6,940 KB
testcase_16 AC 8 ms
6,940 KB
testcase_17 AC 50 ms
6,944 KB
testcase_18 AC 15 ms
6,944 KB
testcase_19 AC 74 ms
6,940 KB
testcase_20 AC 49 ms
6,940 KB
testcase_21 AC 32 ms
6,940 KB
testcase_22 AC 21 ms
6,944 KB
testcase_23 AC 70 ms
6,940 KB
testcase_24 AC 78 ms
6,944 KB
testcase_25 AC 47 ms
6,944 KB
testcase_26 AC 75 ms
6,944 KB
testcase_27 AC 61 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= 0; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

void read(){}
template<class Head, class... Tail> void read(Head& head, Tail&... tail){cin >> head;read(tail...);}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

void calc(vector<int> &a,vector<ll> &a_id,vector<ll> &a_nm,int n){
    int xsum=0;
    rep(i,n){
        xsum^=a[i];
        a_id[xsum]++;
    }
    a_nm = a_id;
    rep(i,1024){
        REP(j,i,1024){
            ll t=a_id[i]*a_id[j];
            ll xo=i^j;
            if(j==i)t-=((a_id[i]+1)*a_id[i])/2;
            a_nm[xo]=(a_nm[xo]+t)%MD;
        }
    }
}

int main()
{
    int n,m,k;
    read(n,m,k);
    vector<int> a,b;
    a.resize(n);
    b.resize(m);
    rep(i,n)read(a[i]);
    rep(i,m)read(b[i]);
    vector<ll> a_id,a_nm;
    a_id.resize(1100),a_nm.resize(1100);
    calc(a,a_id,a_nm,n);
    //writes(a_nm);
    vector<ll> b_id,b_nm;
    b_id.resize(1100),b_nm.resize(1100);
    calc(b,b_id,b_nm,m);
    //writes(b_nm);
    ll res=0;
    rep(i,1024){
        rep(j,1024){
            ll t=a_nm[i]*b_nm[j];
            ll xo=i^j;
            if(xo==k)res=(res+t)%MD;
        }
    }
    write(res);
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/
0