結果

問題 No.206 数の積集合を求めるクエリ
ユーザー nanophoto12nanophoto12
提出日時 2023-03-05 15:24:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,015 ms / 7,000 ms
コード長 4,332 bytes
コンパイル時間 4,523 ms
コンパイル使用メモリ 269,616 KB
実行使用メモリ 4,936 KB
最終ジャッジ日時 2023-10-18 04:55:21
合計ジャッジ時間 13,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 32 ms
4,348 KB
testcase_13 AC 27 ms
4,348 KB
testcase_14 AC 32 ms
4,348 KB
testcase_15 AC 31 ms
4,348 KB
testcase_16 AC 31 ms
4,348 KB
testcase_17 AC 57 ms
4,936 KB
testcase_18 AC 30 ms
4,348 KB
testcase_19 AC 52 ms
4,672 KB
testcase_20 AC 29 ms
4,348 KB
testcase_21 AC 37 ms
4,408 KB
testcase_22 AC 37 ms
4,408 KB
testcase_23 AC 53 ms
4,936 KB
testcase_24 AC 1,015 ms
4,936 KB
testcase_25 AC 999 ms
4,672 KB
testcase_26 AC 983 ms
4,348 KB
testcase_27 AC 718 ms
4,348 KB
testcase_28 AC 985 ms
4,408 KB
testcase_29 AC 990 ms
4,408 KB
testcase_30 AC 979 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define M_PI       3.14159265358979323846   // pi

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using t3 = tuple<ll, ll, ll>;
using t4 = tuple<ll, ll, ll, ll>;
using t5 = tuple<ll, ll, ll, ll, ll>;

#define rep(a,n) for(ll a = 0;a < n; a++)
#define rrep(a,n) for(ll a = n-1;a >= 0; a--)

using namespace atcoder;

template <typename T>
static void chmin(T& ref, const T value)
{
	if (ref > value) ref = value;
}

template <typename T>
static void chmax(T& ref, const T value)
{
	if (ref < value) ref = value;
}

template <typename TKey, typename T>
static void chmax(map<TKey, T>& ref, const TKey& key, const T& value)
{
	if (ref.count(key))
	{
		chmax(ref[key], value);
		return;
	}
	ref[key] = value;
}

typedef modint998244353 mint;

constexpr ll mod = 998244353;

static constexpr ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

static constexpr ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; }
	ll operator[](int k) { return F[k]; }
	const vector<ll>& factors() { return F; }
};

struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};

struct topoloricalSort_runnner2 {
	vector<int> input;

	ll topologicalSort(
		const vector<set<int>>& graph, 
		vector<int> vCounts) {
		int n = graph.size();
		//入次数
		input.assign(n, 0);
		rep(i, n) {
			for (auto dest : graph[i]) {
				input[dest]++;
			}
		}
		queue<int> q;
		rep(i, n) {
			if (input[i] == 0) {
				q.push(i);
			}
		}
		ll sum = 0;
		vector<ll> add(n, 0);
		while (!q.empty()) {
			auto from = q.front(); q.pop();
			for (auto next : graph[from]) {
				//すべての親を処理し終わったら処理する
				sum += vCounts[next] * vCounts[from];
				add[next]+= vCounts[from];
				input[next]--;
				if (input[next] == 0) {
					vCounts[next] += add[next];
					q.push(next);
				}
			}
		}
		return sum;
	}
};

int main()
{
	ll l, m, n;
	cin >> l >> m >> n;
	vector<ll> as(l), bs(m);
	rep(i, l)cin >> as[i];
	rep(i, m)cin >> bs[i];
	bitset<(ll)1e5+1> bit1, bit2;
	rep(i, l){
		bit1.set(as[i]);
	}
	rep(i, m){
		bit2.set(bs[i]);
	}
	ll q;
	cin >> q;
	rep(i, q){
		auto b3 = bit1 & bit2;
		cout << b3.count() << endl;
		bit2 <<= 1;
	}
	return 0;
}
0