結果

問題 No.206 数の積集合を求めるクエリ
ユーザー sugim48sugim48
提出日時 2015-05-08 23:05:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,295 ms / 7,000 ms
コード長 1,211 bytes
コンパイル時間 2,870 ms
コンパイル使用メモリ 91,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 07:39:36
合計ジャッジ時間 26,549 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 52 ms
4,376 KB
testcase_18 AC 28 ms
4,380 KB
testcase_19 AC 47 ms
4,384 KB
testcase_20 AC 27 ms
4,376 KB
testcase_21 AC 33 ms
4,380 KB
testcase_22 AC 33 ms
4,380 KB
testcase_23 AC 48 ms
4,380 KB
testcase_24 AC 3,295 ms
4,380 KB
testcase_25 AC 3,294 ms
4,376 KB
testcase_26 AC 3,272 ms
4,376 KB
testcase_27 AC 2,384 ms
4,376 KB
testcase_28 AC 3,273 ms
4,380 KB
testcase_29 AC 3,269 ms
4,380 KB
testcase_30 AC 3,292 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int L, M, N; cin >> L >> M >> N;
	int n = N / 16 + 1;
	vector<unsigned> a(n);
	while (L--) {
		int A; cin >> A;
		A--;
		a[A / 32] |= 1 << (A % 32);
	}
	vector<unsigned> b(n);
	while (M--) {
		int B; cin >> B;
		B--;
		b[B / 32] |= 1 << (B % 32);
	}
	int Q; cin >> Q;
	for (int v = 0; v < Q; v++) {
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum += __builtin_popcount(a[i] & b[i]);
		cout << sum << endl;
		int x = 0;
		for (int i = 0; i < n; i++) {
			int _x = b[i] >> 31;
			b[i] = (b[i] << 1) + x;
			x = _x;
		}
	}

}
0