結果

問題 No.206 数の積集合を求めるクエリ
ユーザー 古寺いろは古寺いろは
提出日時 2015-05-08 23:50:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,431 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 151,652 KB
実行使用メモリ 5,020 KB
最終ジャッジ日時 2023-09-19 09:02:52
合計ジャッジ時間 6,999 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int bitcount(long long bits){
	bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
	bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
	bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
	bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
	bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
	return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff);
}

int main() {
	int L, M, N;
	cin >> L >> M >> N;
	vector<int> A(L);
	vector<int> B(M);
	vector<int> Bpos(N + 100);
	for (int i = 0; i < L; i++)
	{
		cin >> A[i];
		A[i]--;
	}
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
		B[i]--;
		Bpos[B[i]]++;
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	int Q;
	cin >> Q;

	vector<int> ans(Q + 100, 0);
	for (int j = 0; j < 60; j++)
	{
		vector<long long> al(L / 64 + 1);
		for (int i = 0; i < A.size(); i++)
		{
			if (A[i] < j) continue;
			al[(A[i] - j) / 60] |= 1ll << (A[i] % 60);
		}

		for (int i = 0; i < (N - j + 59) / 60; i++)
		{
			long long bit = 0;
			for (int k = 0; k < 60; k++)
			{
				if (Bpos[i * 60 + j + k] == 1){
					bit |= 1ll << k;
				}
			}
			for (int k = i; k < (N - j + 59) / 60; k++)
			{
				ans[j + (k - i) * 60] += bitcount(al[k] & bit);
			}
		}
	}
	for (int i = 0; i < Q; i++)
	{
		cout << ans[i] << endl;
	}
	cin >> N;

	



}
0