結果
| 問題 |
No.206 数の積集合を求めるクエリ
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2016-01-16 17:20:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,033 ms / 7,000 ms |
| コード長 | 1,344 bytes |
| コンパイル時間 | 1,197 ms |
| コンパイル使用メモリ | 160,724 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 20:03:40 |
| 合計ジャッジ時間 | 9,603 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class QueryOfNumberProductSet
{
public:
void solve(void)
{
int L,M,N;
cin>>L>>M>>N;
// A[i],B[i] の上限が高々 10^5 であること
// A,B にて同じ数字が存在しないこと
// から A,B を bitset で扱うと A & B の計算、 B の一律加算が簡単に表現できる
bitset<100001> A;
bitset<100001> B;
REP(i,L)
{
int x;
cin>>x;
A.set(x);
}
REP(i,M)
{
int x;
cin>>x;
B.set(x);
}
int Q;
cin>>Q;
// O(Q*N/64)
REP(v,Q)
{
cout<<(A & B).count()<<endl;
// 加算によってビットが左にずれる
B <<= 1;
}
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new QueryOfNumberProductSet();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth