結果

問題 No.670 log は定数
ユーザー AquariusAquarius
提出日時 2018-11-06 11:37:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,010 ms / 4,000 ms
コード長 1,076 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 78,792 KB
実行使用メモリ 20,528 KB
最終ジャッジ日時 2024-04-30 22:11:26
合計ジャッジ時間 11,858 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 901 ms
20,408 KB
testcase_01 AC 1,010 ms
20,376 KB
testcase_02 AC 973 ms
20,416 KB
testcase_03 AC 935 ms
20,348 KB
testcase_04 AC 953 ms
20,332 KB
testcase_05 AC 922 ms
20,508 KB
testcase_06 AC 925 ms
20,424 KB
testcase_07 AC 920 ms
20,528 KB
testcase_08 AC 1,007 ms
20,412 KB
testcase_09 AC 948 ms
20,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

ull seed;
uint 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<uint> a(n);
    for (int i = 0; i < n; i++) {
    	a[i] = next();
    }
	sort(a.begin(), a.end());
  	a.push_back(0xffffffff);
  
	const uint shift = 9;
	const uint types = 1 << (31 - shift); 
	vector<int> b(types + 1);
  	uint curr = 0;
	for (int i = 0; i < n; ++i) {
    	if (a[i] >= (curr << shift)) {
        	b[curr] = i;
        	++curr;
        	--i;
        }
    }
  	b[types] = n;
  
    ll ans = 0;
    for (int i = 0; i < q; ++i) {
        uint x = next();
    	uint s = x >> shift;
    	uint cnt = b[s];
      	while (a[cnt] < x) {
			++cnt;
        }
        ans ^= ll(cnt) * i;
    }
    cout << ans << endl;
    return 0;
}
0