結果

問題 No.670 log は定数
ユーザー どららどらら
提出日時 2018-03-24 00:49:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,196 ms / 4,000 ms
コード長 1,376 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 175,632 KB
実行使用メモリ 17,196 KB
最終ジャッジ日時 2023-09-07 07:51:31
合計ジャッジ時間 24,764 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,948 ms
16,888 KB
testcase_01 AC 2,111 ms
17,020 KB
testcase_02 AC 1,984 ms
16,960 KB
testcase_03 AC 2,040 ms
17,068 KB
testcase_04 AC 2,069 ms
17,016 KB
testcase_05 AC 1,935 ms
17,072 KB
testcase_06 AC 1,962 ms
17,036 KB
testcase_07 AC 1,942 ms
17,196 KB
testcase_08 AC 2,196 ms
16,948 KB
testcase_09 AC 2,034 ms
16,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

#define PART 300000

int sn;
vector<ll> ma[PART+10];
ll sma[PART+10];
vector<int> a;

inline int solve(ll x){
  ll part = (2LL<<31)/PART;

  ll pos = x/part;
  ll ret = sma[pos];
  if(ma[pos].size() == 0) return ret;
  
  int m;
  int l = 0, r = ma[pos].size();
  while(l<r){
    m = (l+r)/2;
    if(ma[pos][m]<x) l = m+1; else r = m;
  }

  return ret + l;
}

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

  for (int i = 0; i < n; i++){
    int x = next();
    a.push_back(x);
  }
  sort(ALLOF(a));

  ll part = (2LL<<31)/PART;
  for(int i=0; i<n; i++){
    ma[a[i]/part].push_back(a[i]);
  }
  sma[0] = 0;
  sort(ALLOF(ma[0]));
  for(int i=1; i<PART; i++){
    sma[i] = sma[i-1] + ma[i-1].size();
    sort(ALLOF(ma[i]));
  }

  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