QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#823043#9156. 百万富翁DinoHadzic100 ✓2683ms86332kbC++141.5kb2024-12-20 18:36:112024-12-20 18:36:21

Judging History

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

  • [2024-12-20 18:36:21]
  • 评测
  • 测评结果:100
  • 用时:2683ms
  • 内存:86332kb
  • [2024-12-20 18:36:11]
  • 提交

answer

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

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const int NN = 1e6;

int arr[] = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};

int richest(int n, int t, int s) {
	int subt = 0;
	if (t == 1) subt = 7;
	
	vector <int> cur, ncur;
	if (!subt) for (int i = 0; i < NN; i++) cur.pb(i);
	else for (int i = 0; i < n; i++) cur.pb(i);
	
	for (int i = subt; i < 8; i++) {
		vector <int> v1, v2;
		ncur.clear();
		int x = cur.size(), k = arr[i];
		int y = x%k, z = x/k, uk = 0;
		int si[] = {y, k-y}, co[] = {z+1, z};
		for (int o = 0; o < 2; o++) {
			for (int i = 0; i < si[o]; i++) {
				for (int a = 0; a < co[o]; a++) for (int b = a+1; b < co[o]; b++) {
					if (uk+i*co[o]+b >= n) continue;
					v1.pb(cur[uk+i*co[o]+a]);
					v2.pb(cur[uk+i*co[o]+b]);
				}
			}
			uk += si[o]*co[o];
		}
		vector <int> v = ask(v1, v2);
		int br = 0; uk = 0;
		vector <int> deg(NN, 0);
		for (int o = 0; o < 2; o++) {
			for (int i = 0; i < si[o]; i++) {
				for (int a = 0; a < co[o]; a++) for (int b = a+1; b < co[o]; b++) {
					if (cur[uk+i*co[o]+b] < n) deg[v[br++]]++;
					else deg[cur[uk+i*co[o]+a]]++;
				}
				for (int a = 0; a < co[o]; a++) if (deg[cur[uk+i*co[o]+a]] == co[o]-1) ncur.pb(cur[uk+i*co[o]+a]);
			}
			uk += si[o]*co[o];
		}
		swap(ncur, cur);
	}
	return cur[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 641ms
memory: 27064kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2681ms
memory: 86324kb

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: 629ms
memory: 27684kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2683ms
memory: 86332kb

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