結果

問題 No.206 数の積集合を求めるクエリ
ユーザー eitahoeitaho
提出日時 2015-05-09 00:09:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 874 ms / 7,000 ms
コード長 1,174 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 80,648 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-19 09:06:55
合計ジャッジ時間 8,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 31 ms
4,380 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 31 ms
4,384 KB
testcase_15 AC 30 ms
4,376 KB
testcase_16 AC 30 ms
4,380 KB
testcase_17 AC 38 ms
4,380 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 20 ms
4,380 KB
testcase_21 AC 24 ms
4,380 KB
testcase_22 AC 24 ms
4,380 KB
testcase_23 AC 35 ms
4,380 KB
testcase_24 AC 874 ms
4,380 KB
testcase_25 AC 872 ms
4,504 KB
testcase_26 AC 857 ms
4,380 KB
testcase_27 AC 642 ms
4,380 KB
testcase_28 AC 868 ms
4,376 KB
testcase_29 AC 863 ms
4,376 KB
testcase_30 AC 855 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <climits>
#include <numeric>
#include <functional>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
template<class T> void checkmin(T &a, T b) { if (b < a) a = b; }
template<class T> void checkmax(T &a, T b) { if (b > a) a = b; }


const int MaxN = 100000;
int NA, NB, N, Q, A[MaxN], B[MaxN];

void solve() {
    sort(A, A + NA);
    sort(B, B + NB);
    bitset<MaxN> bitA, bitB;
    rep(i, NA) bitA.set(A[i] - 1);
    rep(i, NB) bitB.set(B[i] - 1);
    rep(add, Q) {
        int ans = (bitA & (bitB << add)).count();
        printf("%d\n", ans);
    }
}

int main() {
    scanf("%d%d%d", &NA, &NB, &N);
    rep(i, NA) scanf("%d", &A[i]);
    rep(i, NB) scanf("%d", &B[i]);
    scanf("%d", &Q);
    solve();
    return 0;
}
0