QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502190#9156. 百万富翁maxrgby#0 0ms0kbC++141.2kb2024-08-03 01:22:532024-08-03 01:22:53

Judging History

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

  • [2024-08-03 01:22:53]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-08-03 01:22:53]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;

// int arr[1000005];

// vector<int> ask(vector<int> a, vector<int> b){
// 	vector<int> ret;
// 	for(int i = 0;i < a.size();i++){
// 		if(arr[a[i]] > arr[b[i]]){
// 			ret.push_back(a[i]);
// 		}else{
// 			ret.push_back(b[i]);
// 		}
// 	}
// 	return ret;
// }

int richest(int n, int t, int s) {
	assert(t >= ceil(log2(n)));
	assert(s >= 2*n);
	set<int> nums;
	for(int i = 0;i < n;i++){
		nums.insert(i);
	}
	while(t--){
		vector<int> a,b;
		int i = 0;
		for(auto it = nums.begin();it != nums.end();it++,i++){
			if(i&1){
				b.push_back(*it);
			}else{
				a.push_back(*it);
			}
		}
		if(a.size() != b.size()){
			b.push_back({*nums.rbegin()});
		}
		vector<int> c = ask(a,b);
		nums.clear();
		for(auto i : c){
			nums.insert(i);
		}
		//cout << "sz=" << nums.size() << endl;
	}
	//cout << "sum=" << sum << endl;
	assert(nums.size() == 1);
    return *nums.begin();
}

// int main(){
// 	int n,t,s;
// 	cin >> n >> t >> s;
// 	int mx = 0;
// 	for(int i = 0;i < n;i++){
// 		cin >> arr[i];
// 		mx = max(mx,arr[i]);
// 	}
// 	//cout << "mx=" << mx << endl;
// 	//cout << "arr=" << arr[3073] << endl;
// 	cout << richest(n,t,s) << endl;
// }

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Runtime Error

input:

1000 1 499500 957319859

output:

Unauthorized output

result:


Pretest #2:

score: 0
Time Limit Exceeded

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 11 / 85, maxt = 20, maxs = 1000007
2862133516934917577
0.129412
3823502568050958645

result:



Final Tests

Test #1:

score: 0
Runtime Error

input:

1000 1 499500 957319857

output:

Unauthorized output

result:


Test #2:

score: 0
Time Limit Exceeded

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 11 / 85, maxt = 20, maxs = 1000007
2862133516934917577
0.129412
3823502568050958645

result: