結果
問題 |
No.206 数の積集合を求めるクエリ
|
ユーザー |
|
提出日時 | 2017-05-11 16:56:46 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1,138 ms / 7,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 906 ms |
コンパイル使用メモリ | 109,088 KB |
実行使用メモリ | 14,060 KB |
最終ジャッジ日時 | 2024-06-12 19:11:09 |
合計ジャッジ時間 | 10,437 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bitmanip; // BitArray void main() { auto rd = readln.split.to!(size_t[]), l = rd[0], m = rd[1], n = rd[2]; auto ai = readln.split.to!(int[]); auto bi = readln.split.to!(int[]); auto q = readln.chomp.to!int; auto bai = BitArray(); bai.length = n+1; foreach (a; ai) bai[a] = true; auto bbi = BitArray(); bbi.length = n+1; foreach (b; bi) bbi[b] = true; foreach (_; 0..q) { auto bci = bai & bbi; writeln((cast(size_t[])(bci)).map!(i => i.popcnt).sum); bbi <<= 1; } } pragma(inline) { import core.bitop; pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); } }