結果

問題 No.670 log は定数
ユーザー antaanta
提出日時 2018-03-23 23:10:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 464 ms / 4,000 ms
コード長 1,307 bytes
コンパイル時間 1,707 ms
コンパイル使用メモリ 169,676 KB
実行使用メモリ 8,196 KB
最終ジャッジ日時 2023-09-07 04:11:15
合計ジャッジ時間 7,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 442 ms
7,900 KB
testcase_01 AC 442 ms
8,064 KB
testcase_02 AC 448 ms
7,932 KB
testcase_03 AC 443 ms
7,860 KB
testcase_04 AC 443 ms
7,904 KB
testcase_05 AC 441 ms
7,924 KB
testcase_06 AC 455 ms
8,196 KB
testcase_07 AC 443 ms
7,920 KB
testcase_08 AC 464 ms
8,020 KB
testcase_09 AC 455 ms
7,948 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 = 11, 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