結果

問題 No.670 log は定数
ユーザー yosupotyosupot
提出日時 2017-09-12 20:08:34
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2,445 ms / 4,000 ms
コード長 830 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 142,812 KB
実行使用メモリ 5,832 KB
最終ジャッジ日時 2023-09-03 16:16:54
合計ジャッジ時間 28,990 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,445 ms
4,564 KB
testcase_01 AC 2,435 ms
4,820 KB
testcase_02 AC 2,431 ms
4,812 KB
testcase_03 AC 2,435 ms
4,548 KB
testcase_04 AC 2,426 ms
4,496 KB
testcase_05 AC 2,435 ms
4,812 KB
testcase_06 AC 2,429 ms
4,760 KB
testcase_07 AC 2,424 ms
4,812 KB
testcase_08 AC 2,433 ms
4,812 KB
testcase_09 AC 2,443 ms
5,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.algorithm, std.range;

ulong seed;
int next() {
    seed = seed ^ (seed << 13);
    seed = seed ^ (seed >> 7);
    seed = seed ^ (seed << 17);
    return cast(int)(seed >> 33);
}
immutable B = 300000;
immutable S = (1L<<32) / B + 1;

void main() {
    int n; int q;
    readf("%d %d %d\n", &n, &q, &seed);
    foreach (i; 0..10000) next();

    int[] a = new int[n];
    foreach (i; 0..n) a[i] = next();
    a.sort!"a<b";

    int[] l = new int[B+1];
    int c = 0;
    foreach (i; 0..B+1) {
        l[i] = c;
        while (c < n && (a[c] / S) == i) c++;
    }

    long query(int x) {
        int i = x / S;
        return a[l[i]..l[i+1]].assumeSorted.lowerBound(x).length + l[i];
    }

    long sm = 0;
    foreach (i; 0..q) {
        int x = next();
        sm ^= query(x) * i;
    }
    writeln(sm);
}
0