結果

問題 No.206 数の積集合を求めるクエリ
コンテスト
ユーザー tottoripaper
提出日時 2015-05-10 11:07:10
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2,720 ms / 7,000 ms
コード長 679 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 40,000 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-27 07:27:37
合計ジャッジ時間 14,688 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// Wrongri-La Shower

#include<cstdio>

int L, M, N;
unsigned int A[14000], B[14000];
int Q;

int main(){
    scanf("%d %d %d", &L, &M, &N);
    
    for(int i=0;i<L;i++){
        int a;
        scanf("%d", &a);

        A[a-1>>5] |= 1u << (a-1&31);
    }
    
    for(int i=0;i<M;i++){
        int b;
        scanf("%d", &b);

        B[b-1>>5] |= 1u << (b-1&31);
    }

    scanf("%d", &Q);
    for(int i=0;i<Q;i++){
        int res = 0;
        for(int j=(2*N+31)>>5;j>=0;j--){
            res += __builtin_popcount(A[j] & B[j]);
            if(B[j] >> 31 & 1){
                B[j+1] |= 1;
            }
            B[j] <<= 1;
        }

        printf("%d\n", res);
    }
}
0