結果

問題 No.670 log は定数
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-03-24 00:56:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,166 ms / 4,000 ms
コード長 2,392 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 171,176 KB
実行使用メモリ 33,784 KB
最終ジャッジ日時 2023-09-07 08:03:43
合計ジャッジ時間 37,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,141 ms
33,636 KB
testcase_01 AC 3,128 ms
33,644 KB
testcase_02 AC 3,127 ms
33,636 KB
testcase_03 AC 3,148 ms
33,512 KB
testcase_04 AC 3,135 ms
33,632 KB
testcase_05 AC 3,143 ms
33,744 KB
testcase_06 AC 3,157 ms
33,608 KB
testcase_07 AC 3,140 ms
33,576 KB
testcase_08 AC 3,142 ms
33,568 KB
testcase_09 AC 3,166 ms
33,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/








int N, Q;
//---------------------------------------------------------------------------------------------------
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);
}
//---------------------------------------------------------------------------------------------------
const int NV = 1 << 20;
int cnt2[NV];
vector<int> dic[NV];
void _main() {
    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();
    
    int msk = NV - 1;

    rep(i, 0, N) {
        cnt2[a[i]>>20]++;
        dic[a[i]>>20].push_back(a[i]&msk);
    }
    rep(i, 1, NV) cnt2[i] += cnt2[i - 1];
    rep(i, 0, NV) sort(all(dic[i]));

    ll sm = 0;
    for (int i = 0; i < Q; i++) {
        int x = next();

        int cnt = 0;
        //rep(j, 0, N) if (a[j] < x) cnt++;
        int y = x>>20;
        x &= msk;
        if(y) cnt += cnt2[y - 1];
        cnt += lower_bound(all(dic[y]), x) - dic[y].begin();
        sm ^= ll(cnt) * i;
    }
    cout << sm << endl;
}
0