結果

問題 No.206 数の積集合を求めるクエリ
ユーザー airis
提出日時 2015-05-09 14:50:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 79,464 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-05 21:12:59
合計ジャッジ時間 5,729 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;

typedef unsigned long long ull;

int L, M, N, Q;
ull A[1605];
ull B[1605];
ull C[1605];
ull x;
int SIZE = sizeof(ull)*8;
int table16[(1<<16) + 5];

void solve() {
#if 0
	rep(i, 64) {
		printf("%d", (A[0]&(1<<i)) > 0);
	}
	puts("");
#endif
	rep(i, Q) {
		int ans = 0;
		for (int j = 1600; j >= 0; j--) {
			if (i > 0) {
				B[j] <<= 1;
				if (j - 1 >= 0)  {
					B[j] |= (B[j-1] & (1<<(SIZE-1)));
				}
			}
			C[j] = A[j] & B[j];
			ans += table16[(C[j] & 0x000000000000ffff)];
			ans += table16[(C[j] & 0x00000000ffff0000)>>16];
			ans += table16[(C[j] & 0x0000ffff00000000)>>32];
			ans += table16[(C[j] & 0xffff000000000000)>>48];
		}
		cout << ans << endl;
	}
}

int main() {
	cin >> L >> M >> N;
	rep(i, L) {
		cin>> x; x--;
		A[i/SIZE] |= (1 << (x % SIZE));
	}
	rep(i, M) {
		cin>> x; x--;
		B[i/SIZE] |= (1 << (x % SIZE));
	}
	cin >> Q;
	rep(i, 1 << 16) {
		table16[i] = 0;
		rep(j, 16) {
			table16[i] += ((i & (1 << j)) > 0);
		}
	}
	solve();
	return 0;
}


0