結果

問題 No.206 数の積集合を求めるクエリ
ユーザー codershifth
提出日時 2016-01-16 17:08:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 992 ms / 7,000 ms
コード長 1,056 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 161,764 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-19 20:03:21
合計ジャッジ時間 9,490 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;


class QueryOfNumberProductSet
{
public:
    void solve(void)
    {
            int L,M,N;
            cin>>L>>M>>N;

            bitset<100001> A;
            bitset<100001> B;

            REP(i,L)
            {
                int x;
                cin>>x;
                A.set(x);
            }
            REP(i,M)
            {
                int x;
                cin>>x;
                B.set(x);
            }

            int Q;
            cin>>Q;

            REP(v,Q)
            {
                // 加算によってビットが左にずれる
                cout<<(A & B<<v).count()<<endl;
            }
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new QueryOfNumberProductSet();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0