QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491208#9156. 百万富翁xvzhiming#85 2157ms90388kbC++201.5kb2024-07-25 17:35:232024-07-25 17:35:23

Judging History

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

  • [2024-07-25 17:35:23]
  • 评测
  • 测评结果:85
  • 用时:2157ms
  • 内存:90388kb
  • [2024-07-25 17:35:23]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>
#include "richest.h"

using namespace std;

const int N = 1000010, M = 1010;

int ns[] = {1000000, 500000, 250000, 125000, 62497, 20832, 3472, 183, 1};

int solve(int l, int r) {
	if (l == r) return l;
	int mid = (l+r)>>1;
	int x = solve(l, mid), y = solve(mid+1, r);
	return ask({x}, {y})[0];
}

int richest(int n, int k, int s) {
	if (n == (int)1e6) {
	vector <int> ans(N);
	for (int i = 0; i < N; i++) ans[i] = i;
	for (int t = 0; t < 8; t++) {
		int n1 = ns[t], n2 = ns[t+1];
		int a1 = n1/n2, a2 = a1+1;
		int c2 = n1%n2, c1 = n2-c2;
		int m = 1ll*a1*(a1-1)/2*c1+1ll*a2*(a2-1)/2*c2;
		vector<int> a, b;
		for (int i = 0, k = 0, l = 0; i < n2; i++) {
			int r = l;
			if (k < c1) k++, r += a1;
			else r += a2;
			for (int j = l; j < r; j++) {
				for (int p = j+1; p < r; p++) {
					a.push_back(ans[j]);
					b.push_back(ans[p]);
				}
			}
			l = r;
		}
		vector <int> c = ask(a, b);
		vector <int> val(n2);
		for (int i = 0, k = 0, l = 0, t = 0; i < n2; i++) {
			int r = l;
			if (k < c1) k++, r += a1;
			else r += a2;
			static int cnt[N];
			for (int j = l; j < r; j++) cnt[ans[j]] = 0;
			for (int j = l; j < r; j++) {
				for (int p = j+1; p < r; p++) {
					cnt[c[t]]++, t++;
				}
			}
			for (int j = l; j < r; j++) {
				if (cnt[ans[j]] == r-l-1) val[i] = ans[j];
			}
			l = r;
		}
		ans.swap(val);
	}
	return ans[0];
	} // Test #2
	
	return solve(0, n-1);
}

//int main() {
//	
//	return 0;
//}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 1ms
memory: 8072kb

input:

1000 1 499500 957319859

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Pretest #2:

score: 85
Accepted
time: 2157ms
memory: 90388kb

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: 0
Wrong Answer
time: 1ms
memory: 8016kb

input:

1000 1 499500 957319857

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Test #2:

score: 85
Accepted
time: 2150ms
memory: 90256kb

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