結果

問題 No.670 log は定数
ユーザー bal4ubal4u
提出日時 2019-05-17 22:18:27
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 814 ms / 4,000 ms
コード長 1,019 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 30,748 KB
実行使用メモリ 48,756 KB
最終ジャッジ日時 2023-10-17 07:27:34
合計ジャッジ時間 9,691 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 814 ms
48,756 KB
testcase_01 AC 789 ms
48,756 KB
testcase_02 AC 785 ms
48,756 KB
testcase_03 AC 775 ms
48,756 KB
testcase_04 AC 781 ms
48,756 KB
testcase_05 AC 743 ms
48,756 KB
testcase_06 AC 734 ms
48,756 KB
testcase_07 AC 720 ms
48,756 KB
testcase_08 AC 707 ms
48,756 KB
testcase_09 AC 670 ms
48,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.670 log は定数
// 2019.5.17 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef long long ll;
typedef unsigned long long ull;

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

#define SFT  11              // 2^11
#define MAX  (1<<(31-SFT))   //
int a[200005];
int f[MAX+3][10], s[MAX+3];
char w[MAX+3];
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int main()
{
	int i, j, x, k, N, Q;
	ll ans;
	
    scanf("%d%d%lld", &N, &Q, &seed);
	i = 10000; while (i--) xorshift();  // gomi
	i = N; while (i--) a[i] = xorshift();
	qsort(a, N, sizeof(int), cmp);
	for (i = 0; i < N; i++) {
		k = a[i] >> SFT;
		f[k][w[k]++] = a[i];
	}
	for (i = 0; i < MAX; i++) s[i+1] = s[i]+w[i];

	ans = 0;
	for (i = 0; i < Q; i++) {
		x = xorshift(), k = x >> SFT;
		for (j = 0; j < w[k]; j++) {
			if (f[k][j] >= x) break;
		}
		ans ^= i * (ll)(s[k]+j);
	}
	printf("%lld\n", ans);
	return 0;
}
0