結果

問題 No.670 log は定数
ユーザー ats5515ats5515
提出日時 2018-03-23 23:14:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,890 ms / 4,000 ms
コード長 1,256 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 81,600 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 04:13:55
合計ジャッジ時間 43,678 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,890 ms
4,384 KB
testcase_01 AC 3,767 ms
4,380 KB
testcase_02 AC 3,807 ms
4,380 KB
testcase_03 AC 3,605 ms
4,380 KB
testcase_04 AC 3,789 ms
4,380 KB
testcase_05 AC 3,650 ms
4,380 KB
testcase_06 AC 3,710 ms
4,380 KB
testcase_07 AC 3,823 ms
4,384 KB
testcase_08 AC 3,841 ms
4,380 KB
testcase_09 AC 3,588 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

int main() {
	int n, q;
	cin >> n >> q >> seed;
	for (int i = 0; i < 10000; i++) next();

	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = next();
	sort(a.begin(), a.end());
	ll sm = 0;
	int w;
	int c;
	double b1 = 1.0 / ((long long)1 << 31);
	double it = n*b1;
	for (int i = 0; i < q; i++) {
		int x = next();
		c = (double)x * n * b1;
		//cerr << c << endl;
		/*if (c < 0 || c >= n) {
			cerr << x << " " << n << " " << b1 << endl;
			cerr << c << endl;
		}*/
		w = n;
		while (true) {
			if (a[c] < x) {
				if (c == n - 1 || a[c + 1] >= x) {
					c++;
					break;
				}
				w = max(2.0, min(w - 2.0,(x - a[c]) * it));
				c += w;
				if (c >= n)c = n - 1;
			}
			else {
				if (c == 0 || a[c - 1] < x)break;
				w = max(2.0, min(w - 2.0, (a[c] - x) * it));
				c -= w; 
				if (c < 0)c = 0;
			}

		}
		sm ^= ll(c) * i;
	}
	cout << sm << endl;
	return 0;
}
0