結果

問題 No.206 数の積集合を求めるクエリ
ユーザー furafura
提出日時 2020-07-28 00:13:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 738 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 199,244 KB
実行使用メモリ 5,260 KB
最終ジャッジ日時 2023-09-11 06:11:58
合計ジャッジ時間 5,684 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,388 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 22 ms
4,380 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 20 ms
4,384 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 14 ms
4,380 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 20 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 #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

inline int popcount(unsigned long long x){
	x-=(x>>1)&0x5555555555555555LL;
	x=(x&0x3333333333333333LL)+((x>>2)&0x3333333333333333LL);
	x=(x+(x>>4))&0x0f0f0f0f0f0f0f0fLL;
	x=(x*0x0101010101010101LL)>>56;
	return x;
}

int main(){
	int m,n; scanf("%d%d%*d",&m,&n);

	unsigned long long A[1600]={},B[1600]={};
	rep(i,m){ int a; scanf("%d",&a); A[a/64]|=1ULL<<a%64; }
	rep(i,n){ int b; scanf("%d",&b); B[b/64]|=1ULL<<b%64; }

	int q; scanf("%d",&q);
	rep(i,q){
		int d1=i/64,d2=i%64;
		int ans=0;
		rep(x,1600-d1){
			auto b=B[x+d1]<<d2;
			if(x+d1>0 && d2>0) b|=B[x+d1-1]>>(64-d2);
			ans+=popcount(A[x]&b);
		}
		printf("%d\n",ans);
	}

	return 0;
}
0