結果

問題 No.670 log は定数
ユーザー te-shte-sh
提出日時 2018-04-20 10:16:07
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 3,844 ms / 4,000 ms
コード長 1,013 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 99,444 KB
実行使用メモリ 54,104 KB
最終ジャッジ日時 2023-09-03 19:55:11
合計ジャッジ時間 34,137 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,149 ms
52,916 KB
testcase_01 AC 2,979 ms
50,864 KB
testcase_02 AC 2,626 ms
53,448 KB
testcase_03 AC 3,004 ms
53,024 KB
testcase_04 AC 2,833 ms
54,104 KB
testcase_05 AC 2,892 ms
51,136 KB
testcase_06 AC 3,844 ms
53,580 KB
testcase_07 AC 3,103 ms
51,684 KB
testcase_08 AC 3,077 ms
52,072 KB
testcase_09 AC 2,678 ms
51,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void pickV(R,T...)(ref R r,ref T t){foreach(ref v;t)pick(r,v);}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

ulong seed;
int next() {
  seed = seed ^ (seed << 13);
  seed = seed ^ (seed >> 7);
  seed = seed ^ (seed << 17);
  return cast(int)(seed >> 33);
}

const tb = 31, ub = 20, db = tb-ub;

void main()
{
  int n, q; readV(n, q, seed);

  foreach (i; 0..10000) next();

  auto a = new int[](n);
  foreach (i; 0..n) a[i] = next();
  a.sort();

  auto b = new int[][](1<<ub);
  foreach (ai; a) b[ai>>db] ~= ai;
  auto c = b.map!(bi => bi.length).array;
  auto cc = new ulong[](1<<ub+1);
  foreach (i; 0..1<<ub) cc[i+1] = cc[i]+c[i];

  auto ans = 0uL;
  foreach (i; 0..q) {
    auto x = next(), xi = (x>>db);
    ans ^= (cc[xi] + b[xi].count!(bi => bi < x)) * i;
  }

  writeln(ans);
}
0