QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489477#9156. 百万富翁zhjxaoini100 ✓2345ms82808kbC++143.0kb2024-07-24 20:32:082024-07-24 20:32:08

Judging History

你现在查看的是最新测评结果

  • [2024-07-24 20:32:08]
  • 评测
  • 测评结果:100
  • 用时:2345ms
  • 内存:82808kb
  • [2024-07-24 20:32:08]
  • 提交

answer

#ifndef LOCAL_RUN
	#define NDEBUG
#endif
#ifdef GNU_DEBUG
	#define _GLIBCXX_DEBUG 1
	#define _GLIBCXX_DEBUG_PEDANTIC 1
	#define _GLIBCXX_SANITIZE_VECTOR 1
#endif
#include <bits/stdc++.h>
#include "richest.h"
#define mset(a, b) memset(&a, b, sizeof(a))
#define ALL(v) std::begin(v), std::end(v)
#define RANGE(a, l, r) (std::begin(a) + (l)), (std::begin(a) + ((r) + 1))
#define fir(i, a, b, ...) for (int i = (a), ##__VA_ARGS__; i <= (b); ++i)
#define firr(i, a, b, ...) for (int i = (a), ##__VA_ARGS__; i >= (b); --i)
#ifdef LOCAL_RUN
	template<class T> void dbgpr(const T& x) {std::cerr << x << std::endl;}
	template<class T, class... Args> void dbgpr(const T& x, const Args&... args) {std::cerr << x << ", ", dbgpr(args...);}
	template<class... Args> void dbgprint(const char* s, const Args&... args) {std::cerr << s << " = ", dbgpr(args...);}
	#define debug(...) dbgprint(#__VA_ARGS__, __VA_ARGS__)
	#define DEBUG if (true)
#else
	#define debug(...) void()
	#define DEBUG if (false)
#endif
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
template<class T> void rei(T& x) {
	bool f = false; int ch; x = 0;
	while (!isdigit(ch = getchar())) f = ch == '-';
	do x = x * 10 + (ch & 15); while (isdigit(ch = getchar()));
	if (f) x = -x;
}
template<class T1, class T2> bool cmax(T1& a, const T2& b) {return a < b ? a = b, true : false;}
template<class T1, class T2> bool cmin(T1& a, const T2& b) {return b < a ? a = b, true : false;}
using namespace std;

const int MAXN = 1e6 + 5;

void build(vector<int>& op1, vector<int>& op2, vector<int>& seq, int C) {
	assert((int)seq.size() >= C);
	vector<int> cur; cur.reserve(C);
	fir (i, 1, C) cur.push_back(seq.back()), seq.pop_back();
	fir (i, 0, C - 1) fir (j, i + 1, C - 1) {
		op1.push_back(cur[i]);
		op2.push_back(cur[j]);
	}
}
int recover(vector<int>& res, int C) {
	assert((int)res.size() >= C * (C - 1) / 2);
	vector<int> vec; vec.reserve(C * (C - 1) / 2);
	fir (i, 1, C * (C - 1) / 2) vec.push_back(res.back()), res.pop_back();
	sort(ALL(vec));
	int las = 0, now = 0;
	int mx = 0, mxi = 0;
	for (auto& it : vec) {
		if (it != las) las = it, now = 1;
		else now++;
		if (cmax(mx, now)) mxi = it;
	}
	return mxi;
}

vector<int> seq;
void oper(int A, int cnt, int B) {
	assert(A * cnt <= (int)seq.size() && ((int)seq.size() - A * cnt) % B == 0);
	vector<int> op1, op2;
	fir (asdf, 1, cnt) {
		build(op1, op2, seq, A);
	}
	while (seq.size()) {
		build(op1, op2, seq, B);
	}
	assert(seq.empty());
	vector<int> res = ask(move(op1), move(op2));
	reverse(ALL(res));
	fir (asdf, 1, cnt) {
		int cur = recover(res, A);
		seq.push_back(cur);
	}
	while (res.size()) {
		int cur = recover(res, B);
		seq.push_back(cur);
	}
}

int richest(int n, int, int) {
	seq.resize(n), iota(ALL(seq), 0);
	if (n == 1000) {
		oper(0, 0, 1000);
	} else {
		oper(0, 0, 2);
		oper(0, 0, 2);
		oper(0, 0, 2);
		oper(0, 0, 2);
		oper(4, 1, 3);
		oper(7, 1, 6);
		oper(18, 5, 19);
		oper(0, 0, 183);
	}
	assert((int)seq.size() == 1);
	return seq[0];
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 752ms
memory: 20012kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2336ms
memory: 82672kb

input:

1000000 20 2000000 29091473

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944


Final Tests

Test #1:

score: 15
Accepted
time: 744ms
memory: 19540kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2345ms
memory: 82808kb

input:

1000000 20 2000000 29091471

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944