結果

問題 No.670 log は定数
ユーザー merom686merom686
提出日時 2018-03-24 12:19:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 462 ms / 4,000 ms
コード長 1,139 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 78,468 KB
実行使用メモリ 8,300 KB
最終ジャッジ日時 2023-09-07 08:24:38
合計ジャッジ時間 6,194 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 462 ms
8,100 KB
testcase_01 AC 448 ms
7,932 KB
testcase_02 AC 448 ms
8,112 KB
testcase_03 AC 446 ms
7,956 KB
testcase_04 AC 448 ms
8,300 KB
testcase_05 AC 446 ms
8,108 KB
testcase_06 AC 441 ms
8,116 KB
testcase_07 AC 440 ms
8,104 KB
testcase_08 AC 451 ms
7,936 KB
testcase_09 AC 459 ms
7,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

using ll = long long;
using ull = unsigned long long;

ull seed;
int next() {
    seed = seed ^ (seed << 13);
    seed = seed ^ (seed >> 7);
    seed = seed ^ (seed << 17);
    return (seed >> 33);
}

int main() {
    int n, q;
    cin >> n >> q >> seed;

    for (int i = 0; i < 10000; i++) {
        next();
    }

    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        a[i] = next();
    }
    sort(a.begin(), a.begin() + n);
    a[n] = (1U << 31) - 1;

    constexpr int K = 20, L = 31 - K, M = 1 << K;
    vector<int> b(M + 1);
    for (int i = 0; i < n; i++) {
        int j = a[i] >> L;
        b[j + 1]++;
    }
    for (int j = 2; j <= M; j++) {
        b[j] += b[j - 1];
    }

    ll r = 0;
    for (int h = 0; h < q; h++) {
        int x = next();
        int j = x >> L;
        for (int i = b[j];; i++) {
            if (a[i] >= x) {
                r ^= (ll)i * h;
                break;
            }
        }
    }

    cout << r << endl;

    return 0;
}
0