結果

問題 No.670 log は定数
ユーザー antaanta
提出日時 2018-03-23 22:54:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,025 ms / 4,000 ms
コード長 1,404 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 172,108 KB
実行使用メモリ 6,444 KB
最終ジャッジ日時 2023-09-07 03:49:36
合計ジャッジ時間 24,721 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,013 ms
6,316 KB
testcase_01 AC 2,009 ms
6,380 KB
testcase_02 AC 2,017 ms
6,384 KB
testcase_03 AC 2,021 ms
6,308 KB
testcase_04 AC 2,012 ms
6,444 KB
testcase_05 AC 2,025 ms
6,364 KB
testcase_06 AC 2,012 ms
6,380 KB
testcase_07 AC 2,008 ms
6,308 KB
testcase_08 AC 2,011 ms
6,360 KB
testcase_09 AC 2,013 ms
6,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int Q; unsigned long long seed;
	while (~scanf("%d%d%llu", &N, &Q, &seed)) {
		auto next = [&seed]() {
			seed = seed ^ (seed << 13);
			seed = seed ^ (seed >> 7);
			seed = seed ^ (seed << 17);
			return (int)(seed >> 33);
		};
		rep(i, 10000) next();
		vector<int> A(N);
		rep(i, N) A[i] = next();
		sort(A.begin(), A.end());
		vector<vector<int>> buckets(1 << 15);
		for(int a : A)
			buckets[a >> 16].push_back(a);
		vector<int> sumSize(buckets.size() + 1);
		rep(i, buckets.size())
			sumSize[i + 1] = sumSize[i] + (int)buckets[i].size();

		ll anssum = 0;
		rep(qi, Q) {
			int x = next();
			int ans = sumSize[x >> 16];
			auto &v = buckets[x >> 16];
			ans += (int)(lower_bound(v.begin(), v.end(), x) - v.begin());
			anssum ^= (ll)ans * qi;
		}

		printf("%lld\n", anssum);
	}
	return 0;
}
0