結果

問題 No.670 log は定数
ユーザー yosupotyosupot
提出日時 2017-09-12 20:11:16
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2,257 ms / 4,000 ms
コード長 827 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 142,596 KB
実行使用メモリ 5,528 KB
最終ジャッジ日時 2023-09-03 16:17:42
合計ジャッジ時間 27,417 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,180 ms
4,488 KB
testcase_01 AC 2,179 ms
4,548 KB
testcase_02 AC 2,175 ms
5,528 KB
testcase_03 AC 2,191 ms
4,524 KB
testcase_04 AC 2,187 ms
4,516 KB
testcase_05 AC 2,194 ms
4,776 KB
testcase_06 AC 2,209 ms
4,516 KB
testcase_07 AC 2,227 ms
4,544 KB
testcase_08 AC 2,257 ms
4,732 KB
testcase_09 AC 2,198 ms
4,528 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];
    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