結果

問題 No.670 log は定数
ユーザー antaanta
提出日時 2018-03-23 23:12:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 629 ms / 4,000 ms
コード長 1,307 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 169,944 KB
実行使用メモリ 12,336 KB
最終ジャッジ日時 2023-09-07 04:12:26
合計ジャッジ時間 9,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 621 ms
12,092 KB
testcase_01 AC 602 ms
12,104 KB
testcase_02 AC 596 ms
11,976 KB
testcase_03 AC 607 ms
11,984 KB
testcase_04 AC 612 ms
12,088 KB
testcase_05 AC 597 ms
12,104 KB
testcase_06 AC 608 ms
12,104 KB
testcase_07 AC 629 ms
12,184 KB
testcase_08 AC 577 ms
12,336 KB
testcase_09 AC 605 ms
12,048 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 (uint32_t)(seed >> 33);
		};
		rep(i, 10000) next();
		vector<uint32_t> A(N + 1);
		rep(i, N) A[i] = next();
		A[N] = 0xffffffffu;
		sort(A.begin(), A.end());
		const int shift = 10, M = 1 << (31 - shift);
		vector<int> index(M + 1);
		rep(i, N) ++ index[(A[i] >> shift) + 1];
		rep(i, M) index[i + 1] += index[i];
		ll anssum = 0;
		rep(qi, Q) {
			auto x = next();
			int i = index[x >> shift];
			for (; A[i] < x; ++ i);
			anssum ^= (ll)i * qi;
		}
		printf("%lld\n", anssum);
	}
	return 0;
}
0