結果

問題 No.206 数の積集合を求めるクエリ
ユーザー pekempeypekempey
提出日時 2016-04-01 17:47:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,095 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 161,204 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 07:07:37
合計ジャッジ時間 10,193 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 12 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int input()’:
main.cpp:36:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 | long long input() { long long x; scanf("%lld", &x); return x; }
      |                                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct Bitset {
	vector<unsigned long long> dat;
	int n, m;
	Bitset(int n) : n(n), dat((n + 63) / 64 + 1) { m = dat.size() - 1; }
	int count() {
		int result = 0;
		for (int x : dat) result += __builtin_popcount(x);
		return result;
	}
	void set(int k) {
		dat[k >> 6] |= 1ull << (k & 0x3f);
	}
	Bitset operator&(const Bitset &rhs) const {
		Bitset result(n);
		for (int i = 0; i < m; i++) {
			result.dat[i] = dat[i] & rhs.dat[i];
		}
		return result;
	}
	Bitset &operator<<=(int k) {
		int d = k >> 6ull;
		int e = k & 0x3f;
		for (int i = m - 1; i >= d; i--) {
			dat[i] = dat[i - d];
			dat[i + 1] |= dat[i] >> 64ull - e;
			dat[i] <<= e;
		}
		for (int i = 0; i < d; i++) dat[i] = 0;
		return *this;
	}
};

long long input() { long long x; scanf("%lld", &x); return x; }

int main() {
	int L, M, N;
	cin >> L >> M >> N;

	Bitset A(101010), B(101010);
	for (int i = 0; i < L; i++) A.set(input());
	for (int i = 0; i < M; i++) B.set(input());

	int Q;
	cin >> Q;

	for (int i = 0; i < Q; i++) {
		cout << (A & B).count() << endl;
		B <<= 1;
	}
}
0