結果

問題 No.206 数の積集合を求めるクエリ
ユーザー te-shte-sh
提出日時 2017-05-11 16:56:46
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 1,252 ms / 7,000 ms
コード長 684 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 95,028 KB
実行使用メモリ 14,640 KB
最終ジャッジ日時 2023-09-03 13:19:23
合計ジャッジ時間 12,005 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 6 ms
4,384 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 5 ms
4,384 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 30 ms
7,476 KB
testcase_18 AC 15 ms
6,044 KB
testcase_19 AC 26 ms
7,188 KB
testcase_20 AC 15 ms
6,012 KB
testcase_21 AC 18 ms
6,728 KB
testcase_22 AC 19 ms
6,808 KB
testcase_23 AC 27 ms
7,324 KB
testcase_24 AC 1,252 ms
14,640 KB
testcase_25 AC 1,218 ms
7,320 KB
testcase_26 AC 1,199 ms
6,924 KB
testcase_27 AC 856 ms
6,816 KB
testcase_28 AC 1,161 ms
7,072 KB
testcase_29 AC 1,190 ms
7,008 KB
testcase_30 AC 1,209 ms
7,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)); }
}
0