結果

問題 No.670 log は定数
ユーザー yosupotyosupot
提出日時 2017-09-10 04:06:45
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2,842 ms / 4,000 ms
コード長 868 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 142,632 KB
実行使用メモリ 6,804 KB
最終ジャッジ日時 2023-09-03 16:13:11
合計ジャッジ時間 34,605 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,841 ms
6,524 KB
testcase_01 AC 2,842 ms
5,808 KB
testcase_02 AC 2,841 ms
5,684 KB
testcase_03 AC 2,832 ms
6,804 KB
testcase_04 AC 2,837 ms
6,320 KB
testcase_05 AC 2,830 ms
5,992 KB
testcase_06 AC 2,837 ms
6,060 KB
testcase_07 AC 2,805 ms
5,740 KB
testcase_08 AC 2,833 ms
5,792 KB
testcase_09 AC 2,810 ms
5,776 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 c = 0;
    foreach (i; 0..B) {
        l[i] = c;
        while (c < n && (a[c] / S) == i) c++;
        r[i] = c;
    }

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

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