結果

問題 No.670 log は定数
ユーザー PachicobuePachicobue
提出日時 2018-07-28 04:49:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,885 ms / 4,000 ms
コード長 1,104 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 205,652 KB
実行使用メモリ 9,896 KB
最終ジャッジ日時 2023-09-19 05:58:39
合計ジャッジ時間 23,847 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,847 ms
9,680 KB
testcase_01 AC 1,862 ms
9,520 KB
testcase_02 AC 1,858 ms
9,528 KB
testcase_03 AC 1,838 ms
9,568 KB
testcase_04 AC 1,859 ms
9,572 KB
testcase_05 AC 1,866 ms
9,896 KB
testcase_06 AC 1,885 ms
9,568 KB
testcase_07 AC 1,868 ms
9,500 KB
testcase_08 AC 1,857 ms
9,852 KB
testcase_09 AC 1,871 ms
9,620 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;
    constexpr int B = 1 << 17, S = 1 << 15;
    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(); }
    std::sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) { 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] + std::lower_bound(in[b].begin(), in[b].end(), x) - in[b].begin();
        ans ^= (sub * i);
    }
    std::cout << ans << std::endl;
    return 0;
}
0