結果
問題 | No.670 log は定数 |
ユーザー |
|
提出日時 | 2018-04-19 18:41:46 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1,948 ms / 4,000 ms |
コード長 | 1,178 bytes |
コンパイル時間 | 917 ms |
コンパイル使用メモリ | 108,124 KB |
実行使用メモリ | 36,148 KB |
最終ジャッジ日時 | 2024-06-13 00:45:39 |
合計ジャッジ時間 | 11,986 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
外部呼び出し有り |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
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 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);}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();auto b = new int[][](1<<20);foreach (ai; a) b[ai>>11] ~= ai;auto c = b.map!(bi => bi.length.to!int).array;auto cc = cumulativeSum(c);auto ans = 0uL;foreach (i; 0..q) {auto x = next();ans ^= (cc[0..x>>11] + b[x>>11].count!(bi => bi < x)) * i;}writeln(ans);}class CumulativeSum(T){size_t n;T[] s;this(T[] a){n = a.length;s = new T[](n+1);s[0] = T(0);foreach (i; 0..n) s[i+1] = s[i] + a[i];}T opSlice(size_t l, size_t r) { return s[r]-s[l]; }size_t opDollar() { return n; }}auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }