結果

問題 No.670 log は定数
コンテスト
ユーザー どらら
提出日時 2018-03-23 23:18:28
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3,844 ms / 4,000 ms
コード長 1,141 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,277 ms
コンパイル使用メモリ 196,000 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 03:01:48
合計ジャッジ時間 44,031 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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);
}

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(ALLOF(a));

  vector<pair<int,int>> query;

  ll sm = 0;
  for (int i = 0; i < q; i++) {
    int x = next();
    query.push_back(make_pair(x,i));

    if(query.size() == 10000 || i == q-1){
      sort(ALLOF(query));

      int pos = 0;
      rep(j,query.size()){
        int x = query[j].first;
        int id = query[j].second;
        while(pos < a.size() && a[pos] < x) pos++;
        //cout << x << " " << pos << endl;
        sm ^= (ll)(pos) * id;
      }

      query.clear();
    }
  }

  cout << sm << endl;
  return 0;
}
0