結果

問題 No.670 log は定数
ユーザー face4face4
提出日時 2020-01-31 16:36:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,666 ms / 4,000 ms
コード長 1,043 bytes
コンパイル時間 4,111 ms
コンパイル使用メモリ 76,520 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2023-10-17 08:21:03
合計ジャッジ時間 31,492 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,505 ms
13,488 KB
testcase_01 AC 2,528 ms
13,752 KB
testcase_02 AC 2,563 ms
13,488 KB
testcase_03 AC 2,523 ms
13,488 KB
testcase_04 AC 2,537 ms
13,752 KB
testcase_05 AC 2,559 ms
13,488 KB
testcase_06 AC 2,666 ms
13,488 KB
testcase_07 AC 2,658 ms
13,752 KB
testcase_08 AC 2,603 ms
13,488 KB
testcase_09 AC 2,525 ms
13,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
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 len = (1ll<<31)/(200000)+1;
vector<int> block[200001];
vector<int> cnt(200001, 0);

int main() {
    int n, q;
    cin >> n >> q >> seed;
    for (int i = 0; i < 10000; i++) next();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = next();
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        block[a[i]/len].push_back(a[i]);
        cnt[a[i]/len]++;
    }
    for(int i = 1; i < 200001; i++) cnt[i] += cnt[i-1];
    ll sum = 0;
    for(int i = 0; i < q; i++){
        int x = next();
        int pos = x/len;
        int tmp = pos==0 ? 0 : cnt[pos-1];
        for(int j : block[pos]){
            if(j < x)   tmp++;
            else        break;
        }
        sum ^= (ll)tmp * i;
    }
    cout << sum << endl;
    return 0;
}
0