QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502404#9156. 百万富翁Insert_Username_Here#91.00003 2265ms97724kbC++201.7kb2024-08-03 05:05:142024-08-03 05:05:17

Judging History

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

  • [2024-08-03 05:05:17]
  • 评测
  • 测评结果:91.00003
  • 用时:2265ms
  • 内存:97724kb
  • [2024-08-03 05:05:14]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll mod = 1e9 + 7;
// cope counter = 2254

int num[8] = {1, 2, 2, 2, 2, 3, 6, 19};
vector<int> arr, nxt, a, b, c, diff;

int richest(int st, int end) {
	int rich = 0, i = st;
	for(; i < min((int)a.size(), end); i++) {
		if(i == st || a[i] != a[i - 1]) {
			if(rich) return a[i - 1];
			rich = 1;
		}
		if(c[i] != a[i]) rich = 0;
	}
	return c[i - 1];
}
int bf() {
	int n = arr.size();
	if(n == 1) return arr[0];
	a.clear(), b.clear();
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) a.push_back(arr[i]), b.push_back(arr[j]);
	}
	c = ask(a, b);
	return richest(0, a.size());
}
int richest(int n, int t, int s) {
	arr.resize(n);
	for(int i = 0; i < n; i++) arr[i] = i;
	if(t == 1) return bf();
	for(int i = 1; i < 8; i++) {
		a.clear(), b.clear(), diff.clear();
		int sum = 0;
		while(sum < n) {
			if(num[i] == 3 && !sum) diff.push_back(4);
			else if(num[i] == 6 && !sum) diff.push_back(7);
			else if(num[i] == 19 && sum < 280) diff.push_back(20);
			else diff.push_back(num[i]);
			sum += diff.back();
		}
		for(int j = 0, cur = 0; j < n; j += diff[cur], cur++) {
			for(int i2 = j; i2 < min(n, j + diff[cur]); i2++) {
				for(int j2 = i2 + 1; j2 < min(n, j + diff[cur]); j2++) a.push_back(arr[i2]), b.push_back(arr[j2]);
			}
		}
		c = ask(a, b);
		nxt.clear();
		for(int st = 0, i = 0; st < (int)a.size(); st += diff[i] * (diff[i] - 1) / 2, i++) nxt.push_back(richest(st, st + diff[i] * (diff[i] - 1) / 2));
		while(b.back() != arr.back()) nxt.push_back(arr.back()), arr.pop_back();
		arr = nxt, n = arr.size();
	}
	return bf();
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 602ms
memory: 24176kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 76
Acceptable Answer
time: 2260ms
memory: 97724kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947


Final Tests

Test #1:

score: 15
Accepted
time: 616ms
memory: 24144kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 76
Acceptable Answer
time: 2265ms
memory: 90092kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947