結果

問題 No.206 数の積集合を求めるクエリ
ユーザー startcppstartcpp
提出日時 2015-05-08 22:47:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,133 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 74,868 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-09-19 07:00:43
合計ジャッジ時間 10,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 6 ms
4,384 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 56 ms
4,468 KB
testcase_18 AC 32 ms
4,380 KB
testcase_19 AC 52 ms
4,380 KB
testcase_20 AC 32 ms
4,380 KB
testcase_21 AC 38 ms
4,384 KB
testcase_22 AC 38 ms
4,380 KB
testcase_23 AC 53 ms
4,384 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//久しぶりに一から解く
//unsigned intにしないと死にます!!
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int l, m, n;
int a[100000], b[100000];
int q;
unsigned int ua[4000], ub[4000];

signed main()
{
	int i, j;
	cin >> l >> m >> n;
	for (i = 0; i < l; i++) {
		cin >> a[i];
		ua[(a[i]/32)] += (1<<(a[i]%32));
	}
	for (i = 0; i < m; i++) {
		cin >> b[i];
		ub[(b[i]/32)] += (1<<(b[i]%32));
	}
	cin >> q;
	
	int bitcnt[65536] = {0};
	for (i = 0; i < 65536; i++) {
		for (j = 0; j < 16; j++) {
			if ((i>>j)&1) {
				bitcnt[i]++;
			}
		}
	}
	
	int len = n/32 + 3;
	static int ans[100000] = {0};
	for (i = 0; i < q; i++) {
		for (j = 0; j < len; j++) {
			unsigned int t = ua[j]&ub[j];
			ans[i] += bitcnt[(t>>16)] + bitcnt[(t&(unsigned int)65535)];
		}
		
		for (j = 0; j < len; j++) {
			ub[j-1] += (ub[j]>>31);
			ub[j] = (ub[j]<<1);
		}
	}
	
	for (i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}
0