結果

問題 No.670 log は定数
ユーザー yosupotyosupot
提出日時 2017-09-10 17:20:27
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2,444 ms / 4,000 ms
コード長 931 bytes
コンパイル時間 3,695 ms
コンパイル使用メモリ 142,756 KB
実行使用メモリ 6,848 KB
最終ジャッジ日時 2023-09-03 16:15:37
合計ジャッジ時間 31,037 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,386 ms
6,076 KB
testcase_01 AC 2,370 ms
6,080 KB
testcase_02 AC 2,343 ms
6,540 KB
testcase_03 AC 2,429 ms
6,324 KB
testcase_04 AC 2,376 ms
6,596 KB
testcase_05 AC 2,369 ms
6,844 KB
testcase_06 AC 2,421 ms
6,092 KB
testcase_07 AC 2,380 ms
6,848 KB
testcase_08 AC 2,376 ms
6,060 KB
testcase_09 AC 2,444 ms
6,296 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[] r = new int[B];
    int[2][] idx = new int[2][B];
    int c = 0;
    foreach (i; 0..B) {
        idx[i][0] = c;
        while (c < n && (a[c] / S) == i) c++;
        idx[i][1] = c;
    }

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

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