結果

問題 No.1142 XOR と XOR
ユーザー DriceDrice
提出日時 2020-07-31 22:20:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 32,372 KB
実行使用メモリ 4,620 KB
最終ジャッジ日時 2023-08-07 22:04:54
合計ジャッジ時間 8,451 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 474 ms
4,480 KB
testcase_04 AC 371 ms
4,380 KB
testcase_05 AC 304 ms
4,384 KB
testcase_06 AC 384 ms
4,376 KB
testcase_07 AC 462 ms
4,620 KB
testcase_08 AC 471 ms
4,608 KB
testcase_09 AC 471 ms
4,620 KB
testcase_10 AC 471 ms
4,564 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 259 ms
4,380 KB
testcase_15 AC 253 ms
4,376 KB
testcase_16 AC 21 ms
4,376 KB
testcase_17 AC 348 ms
4,380 KB
testcase_18 AC 79 ms
4,376 KB
testcase_19 AC 381 ms
4,380 KB
testcase_20 AC 245 ms
4,376 KB
testcase_21 AC 152 ms
4,376 KB
testcase_22 AC 85 ms
4,380 KB
testcase_23 AC 355 ms
4,376 KB
testcase_24 AC 403 ms
4,376 KB
testcase_25 AC 230 ms
4,376 KB
testcase_26 AC 376 ms
4,380 KB
testcase_27 AC 300 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
const long long mod = 1e9+7;
long long countA[2048], countB[2048];
long long map[2048];
int a[200005], b[200005];

void preWork(int seq[],int n,long long count[]){
    for(int i = 0; i < 1024; i++) map[i] = count[i] = 0;
    map[0] = 1;
    int prefix = 0;
    for(int i = 1; i <= n; i++){ 
        int u = prefix^seq[i]; prefix = u;
        for(int j = 0; j < 1024; j++){
            count[j] += map[u^j]; if(count[j]>=mod) count[j] -= mod;
        }
        map[u]++; 
    }
}

int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    preWork(a,n,countA);
    //for(int i = 0; i < 1024; i++) if(countA[i]!=0) printf("countA[%d] = %lld\n",i,countA[i]);
    for(int i = 1; i <= m; i++) scanf("%d",&b[i]);
    preWork(b,m,countB);
    //for(int i = 0; i < 1024; i++) if(countB[i]!=0) printf("countB[%d] = %lld\n",i,countB[i]);
    long long ans = 0;
    for(int i = 0; i < 1024; i++){
        ans += countA[i]*countB[k^i]%mod; if(ans>=mod) ans -= mod;
    }
    printf("%lld\n",ans);
    return 0;
}
0