結果

問題 No.1142 XOR と XOR
ユーザー chielochielo
提出日時 2020-07-31 21:57:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 980 ms / 2,000 ms
コード長 1,282 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 164,360 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:16:30
合計ジャッジ時間 17,176 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 959 ms
6,944 KB
testcase_04 AC 754 ms
6,944 KB
testcase_05 AC 618 ms
6,940 KB
testcase_06 AC 784 ms
6,940 KB
testcase_07 AC 961 ms
6,940 KB
testcase_08 AC 963 ms
6,940 KB
testcase_09 AC 969 ms
6,944 KB
testcase_10 AC 980 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 512 ms
6,940 KB
testcase_15 AC 507 ms
6,944 KB
testcase_16 AC 41 ms
6,944 KB
testcase_17 AC 722 ms
6,944 KB
testcase_18 AC 165 ms
6,940 KB
testcase_19 AC 788 ms
6,940 KB
testcase_20 AC 496 ms
6,940 KB
testcase_21 AC 307 ms
6,940 KB
testcase_22 AC 171 ms
6,940 KB
testcase_23 AC 726 ms
6,944 KB
testcase_24 AC 818 ms
6,940 KB
testcase_25 AC 469 ms
6,940 KB
testcase_26 AC 770 ms
6,940 KB
testcase_27 AC 612 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

const int maxn = 2e5 + 3, maxa = (1 << 10);
const long long mo = 1e9 + 7;

int n, m, a[maxn], b[maxn], K;
long long ac[2][maxa], bc[2][maxa], cac[maxa], cbc[maxa];

int main() {
    scanf("%d%d%d", &n, &m, &K);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    for(int i = 0; i < m; ++i) {
        scanf("%d", b + i);
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < maxa; ++j) {
            int u = j ^ a[i];
            ac[i & 1][u] = ac[~i & 1][j];
        }
        ac[i & 1][a[i]] += 1;
        if(ac[i & 1][a[i]] >= mo)
            ac[i & 1][a[i]] -= mo;
        for(int j = 0; j < maxa; ++j) {
            cac[j] = (cac[j] + ac[i & 1][j]) % mo;
        }
    }
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < maxa; ++j) {
            int u = j ^ b[i];
            bc[i & 1][u] = bc[~i & 1][j];
        }
        bc[i & 1][b[i]] += 1;
        if(bc[i & 1][b[i]] >= mo)
            bc[i & 1][b[i]] -= mo;
        for(int j = 0; j < maxa; ++j) {
            cbc[j] = (cbc[j] + bc[i & 1][j]) % mo;
        }
    }
    long long ans = 0;
    for(int i = 0; i < maxa; ++i) {
        ans = (ans + cac[i] * (long long)cbc[i ^ K]) % mo;
    }
    printf("%lld\n", (ans + (long long)mo) % mo);
    return 0;
}
0