QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527118#9156. 百万富翁TheRaptor77.99996 2034ms85956kbC++171.3kb2024-08-22 10:26:392024-08-22 10:26:40

Judging History

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

  • [2024-08-22 10:26:40]
  • 评测
  • 测评结果:77.99996
  • 用时:2034ms
  • 内存:85956kb
  • [2024-08-22 10:26:39]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
int richest(int n, int t, int s){
	vector<int> a,b,ret;
	if(t==1){
		assert(n==1000);
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				a.push_back(i);
				b.push_back(j);
			}
		}
		ret=ask(a,b);
		int ans=0;
		for(int i=0; i<(int)ret.size(); i++){
			if(a[i]==ans) ans=ret[i];
		}
		return ans;
	}
	vector<int> alive,tmp;
	for(int i=0; i<n; i++) alive.push_back(i);
	long long can=1099950;
	while((int)alive.size()>1){
		int m=alive.size();
		int buc=2;
		if((long long)m*(m-1)/2<=can) buc=m;
		else{
			while((long long)(m+buc-1)/buc*buc*(buc-1)/2<can*4/7){
				buc++;
				if(buc>m) break;
			}
			buc--;
		}
		a.clear(); b.clear();
		for(int i=0; i<m; i+=buc){
			for(int j=0; j<buc; j++){
				for(int k=j+1; k<buc; k++){
					if(i+j>=m||i+j>=m) continue;
					a.push_back(alive[i+j]);
					b.push_back(alive[i+k]);
					can--;
				}
			}
		}
		ret=ask(a,b);
		int cnt=0;
		for(int i=0; i<m; i+=buc){
			int best=alive[i];
			for(int j=0; j<buc; j++){
				for(int k=j+1; k<buc; k++){
					if(i+j>=m||i+j>=m) continue;
					if(a[cnt]==best) best=ret[cnt];
					cnt++;
				}
			}
			tmp.push_back(best);
		}
		swap(tmp,alive);
		tmp.clear();
	}
	return alive[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 601ms
memory: 25384kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 63
Acceptable Answer
time: 2034ms
memory: 85956kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1093249
4767961019022463613
0.741176
16601290867448354019

result:

points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1093249


Final Tests

Test #1:

score: 15
Accepted
time: 611ms
memory: 25208kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 63
Acceptable Answer
time: 2027ms
memory: 85936kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1093249
4767961019022463613
0.741176
16601290867448354019

result:

points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1093249