結果

問題 No.670 log は定数
ユーザー maspymaspy
提出日時 2020-04-24 01:20:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 470 ms / 4,000 ms
コード長 1,028 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 80,304 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2024-04-22 10:37:34
合計ジャッジ時間 6,937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 470 ms
8,524 KB
testcase_01 AC 467 ms
8,508 KB
testcase_02 AC 466 ms
8,552 KB
testcase_03 AC 462 ms
8,288 KB
testcase_04 AC 457 ms
8,660 KB
testcase_05 AC 441 ms
8,516 KB
testcase_06 AC 457 ms
8,496 KB
testcase_07 AC 466 ms
8,532 KB
testcase_08 AC 460 ms
8,516 KB
testcase_09 AC 455 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;

uint a[200010];
int memo[1048580];
int n, q;

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

void make_memo()
{
    for (int i = 0; i < n; i++)
    {
        memo[1+(a[i] >> 11)]++;
    }
    for (int i = 1; i < 1048580; i++)
    {
        memo[i] += memo[i - 1];
    }
}

int solve(ull x)
{
    int i = memo[x >> 11];
    int before = i;
    while (a[i] < x)
    {
        i++;
    }
    return i;
}

int main()
{
    cin >> n >> q >> seed;
    for (int i = 0; i < 10000; i++)
        next();

    for (int i = 0; i < n; i++)
        a[i] = next();

    a[n] = (1ULL << 31);

    sort(a, a + n);

    make_memo();
    ll sm = 0;
    for (int i = 0; i < q; i++)
    {
        int x = next();
        int cnt = solve(x);
        sm ^= ll(cnt) * i;
    }
    cout << sm << endl;
    return 0;
}
0