結果

問題 No.670 log は定数
ユーザー PachicobuePachicobue
提出日時 2018-07-28 04:44:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,087 ms / 4,000 ms
コード長 1,053 bytes
コンパイル時間 2,182 ms
コンパイル使用メモリ 204,324 KB
実行使用メモリ 14,536 KB
最終ジャッジ日時 2023-09-19 05:58:13
合計ジャッジ時間 25,917 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,941 ms
14,336 KB
testcase_01 AC 1,916 ms
14,224 KB
testcase_02 AC 2,016 ms
14,276 KB
testcase_03 AC 1,865 ms
14,536 KB
testcase_04 AC 1,884 ms
14,256 KB
testcase_05 AC 1,849 ms
14,260 KB
testcase_06 AC 1,891 ms
14,256 KB
testcase_07 AC 1,968 ms
14,268 KB
testcase_08 AC 1,958 ms
14,232 KB
testcase_09 AC 2,087 ms
14,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//=================================
// Created on: 2018/07/28 04:24:07
//=================================
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ull = unsigned long long;
int main()
{
    int N, Q;
    ull seed;
    std::cin >> N >> Q >> seed;
    int B = 1 << 2, S = 1 << 30;
    for (; B < N; B <<= 1, S >>= 1) {}
    std::vector<std::vector<int>> in(B);
    auto next = [&]() { return seed = seed ^ (seed << 13), seed = seed ^ (seed >> 7), seed = seed ^ (seed << 17), (seed >> 33); };
    for (int i = 0; i < 10000; i++) next();
    std::vector<int> A(N), C(B, 0);
    for (int i = 0; i < N; i++) { A[i] = next(), in[A[i] / S].push_back(A[i]); }
    for (int i = 1; i < B; i++) { C[i] = C[i - 1] + in[i - 1].size(); }
    ll ans = 0;
    for (ll i = 0; i < Q; i++) {
        const int x = next(), b = x / S;
        ll sub = C[b];
        for (const int e : in[b]) { sub += (e < x ? 1 : 0); }
        ans ^= (sub * i);
    }
    std::cout << ans << std::endl;
    return 0;
}
0