結果
問題 | No.670 log は定数 |
ユーザー |
![]() |
提出日時 | 2018-03-24 00:49:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,135 ms / 4,000 ms |
コード長 | 1,376 bytes |
コンパイル時間 | 2,016 ms |
コンパイル使用メモリ | 177,452 KB |
実行使用メモリ | 17,424 KB |
最終ジャッジ日時 | 2024-06-25 02:12:09 |
合計ジャッジ時間 | 25,177 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#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 300000int 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;}