QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#502272#9156. 百万富翁hypeskynick#100 ✓2866ms104840kbC++141.6kb2024-08-03 02:37:292024-08-03 02:37:30

Judging History

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

  • [2024-08-03 02:37:30]
  • 评测
  • 测评结果:100
  • 用时:2866ms
  • 内存:104840kb
  • [2024-08-03 02:37:29]
  • 提交

answer

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int solveSmall(int n){//task 1 is just a n^2 brute force
//simmilar to first explore task
//surely
	vector<int> x,y;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			x.push_back(i),y.push_back(j);
		}
	}
	vector<int> z=ask(x,y),cnt(n);//ask-2005 refrence 0-0
	for(auto&i:z){
		cnt[i]++;
		if(cnt[i]==n-1)return i;
	}
	return 0;
}
int solveLarge(int n,int s){//bucket sort idea
//solution is to split the entire thing up into sections
//find largest in each section then split it down
	vector<int>idx(n);
	for(int i=0;i<n;i++)
		idx[i]=i;
	
	// vector<int>szs={
	// 	(int)1e5,
	// 	(int)5e4,
	// 	(int)25e3,
	// 	(int)125e2,
	// 	(int)6750,
	// 	(int)3375,
	// 	(int)1e3,
	// 	(int)1};
	vector<int>szs={
		(int)5e5,
		(int)25e4,
		(int)125e3,
		(int)625e2,
		(int)20832,
		(int)3472,
		(int)183,
		(int)1};
	for(int U=0;U<8;U++){
		vector<vector<int>>asks(szs[U]);
		for(int i=0;i<idx.size();i++){//buckets yay
			asks[i%szs[U]].push_back(idx[i]);
		}
		vector<int> x,y;
		for(int i=0;i<szs[U];i++)
			for(int j=0;j<asks[i].size();j++)
				for(int k=j+1;k<asks[i].size();k++)
					x.push_back(asks[i][j]),y.push_back(asks[i][k]);
		vector<int>z=ask(x,y),cnt(n);
		for(auto&i:z)
			cnt[i]++;
		
		idx.resize(szs[U]);
		for(int i=0;i<szs[U];i++){
			idx[i]=-1;
			for(auto&j:asks[i]){
				if(cnt[j]==asks[i].size()-1){
					idx[i]=j;
				}
			}
		}
	}
	return idx[0];
}
int richest(int n, int t,int s){
	if(t==1)return solveSmall(n);
	return solveLarge(n,s);
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 630ms
memory: 25388kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2857ms
memory: 102112kb

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: 609ms
memory: 25284kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2866ms
memory: 104840kb

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