結果
問題 |
No.206 数の積集合を求めるクエリ
|
ユーザー |
|
提出日時 | 2016-04-01 17:47:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,095 bytes |
コンパイル時間 | 1,380 ms |
コンパイル使用メモリ | 162,424 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 08:49:57 |
合計ジャッジ時間 | 10,329 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘long long int input()’: main.cpp:36:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | long long input() { long long x; scanf("%lld", &x); return x; } | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; struct Bitset { vector<unsigned long long> dat; int n, m; Bitset(int n) : n(n), dat((n + 63) / 64 + 1) { m = dat.size() - 1; } int count() { int result = 0; for (int x : dat) result += __builtin_popcount(x); return result; } void set(int k) { dat[k >> 6] |= 1ull << (k & 0x3f); } Bitset operator&(const Bitset &rhs) const { Bitset result(n); for (int i = 0; i < m; i++) { result.dat[i] = dat[i] & rhs.dat[i]; } return result; } Bitset &operator<<=(int k) { int d = k >> 6ull; int e = k & 0x3f; for (int i = m - 1; i >= d; i--) { dat[i] = dat[i - d]; dat[i + 1] |= dat[i] >> 64ull - e; dat[i] <<= e; } for (int i = 0; i < d; i++) dat[i] = 0; return *this; } }; long long input() { long long x; scanf("%lld", &x); return x; } int main() { int L, M, N; cin >> L >> M >> N; Bitset A(101010), B(101010); for (int i = 0; i < L; i++) A.set(input()); for (int i = 0; i < M; i++) B.set(input()); int Q; cin >> Q; for (int i = 0; i < Q; i++) { cout << (A & B).count() << endl; B <<= 1; } }