結果

問題 No.670 log は定数
ユーザー e869120e869120
提出日時 2018-06-09 18:22:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,346 ms / 4,000 ms
コード長 849 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 69,792 KB
実行使用メモリ 239,864 KB
最終ジャッジ日時 2023-09-13 02:18:34
合計ジャッジ時間 27,008 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,290 ms
239,716 KB
testcase_01 AC 2,291 ms
239,676 KB
testcase_02 AC 2,297 ms
239,672 KB
testcase_03 AC 2,290 ms
239,676 KB
testcase_04 AC 2,290 ms
239,736 KB
testcase_05 AC 2,310 ms
239,728 KB
testcase_06 AC 2,346 ms
239,704 KB
testcase_07 AC 2,342 ms
239,724 KB
testcase_08 AC 2,314 ms
239,864 KB
testcase_09 AC 2,287 ms
239,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

unsigned long long seed;

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

void Fill(int rep) {
	for (int i = 0; i < rep; i++) Next();
}

const int P = 23;
int N, Q, A[20000009], B[1 << P]; vector<int>vec[1 << P];

int main() {
	cin >> N >> Q >> seed;
	Fill(10000);
	for (int i = 0; i < N; i++) {
		A[i] = Next();
		B[(A[i] >> (31 - P)) + 1]++;
		vec[(A[i] >> (31 - P))].push_back(A[i]);
	}
	for (int i = 1; i < (1 << P); i++) B[i] += B[i - 1];

	long long ret = 0;
	for (int i = 1; i <= Q; i++) {
		int x = Next();
		int sum = B[x >> (31 - P)];
		for (int j = 0; j < vec[x >> (31 - P)].size(); j++) {
			if (vec[x >> (31 - P)][j] < x) sum++;
		}
		ret ^= 1LL * (i - 1) * sum;
	}
	cout << ret << endl;
	return 0;
}
0