QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488531#9156. 百万富翁JohnAlfnov#100 ✓3053ms126528kbC++141.8kb2024-07-24 10:07:422024-07-24 10:07:43

Judging History

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

  • [2024-07-24 10:07:43]
  • 评测
  • 测评结果:100
  • 用时:3053ms
  • 内存:126528kb
  • [2024-07-24 10:07:42]
  • 提交

answer

#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
int cnt[1000005],tt;
int vist[1000005];
vector<int>query(vector<vector<int>>vv){
	vector<int>a,b;
	for(auto vc:vv){
		int sz=vc.size();
		for(int i=0;i<sz;++i)for(int j=i+1;j<sz;++j){
			a.emplace_back(vc[i]);
			b.emplace_back(vc[j]);
		}
	}
	vector<int>c=ask(a,b);
	int bb=0;
	vector<int>ans;
	for(auto vc:vv){
		int sz=vc.size();
		++tt;
		for(int i=0;i<sz;++i)for(int j=i+1;j<sz;++j){
			vist[vc[i]+vc[j]-c[bb++]]=tt;
		}
		for(int i=0;i<sz;++i)if(vist[vc[i]]!=tt)ans.emplace_back(vc[i]);
	}
	return ans;
}
vector<int>dd(vector<int>vc,int B){
	vector<vector<int>>vv;
	int n=vc.size();
	if(B>0){
		int kk=(n+B-1)/B,ls=n-(kk-1)*B;
		int sl=B-ls,a=kk-sl,b=sl;
		int zz=0;
		while(a--){
			vector<int>vb(B);
			for(int i=0;i<B;++i)vb[i]=vc[zz++];
			vv.emplace_back(vb);
		}
		while(b--){
			vector<int>vb(B-1);
			for(int i=0;i<B-1;++i)vb[i]=vc[zz++];
			vv.emplace_back(vb);
		}
	}else{
		B=-B;
		int kk=n/B,ls=n%B;
		int a=kk-ls,b=ls;
		int zz=0;
		while(a--){
			vector<int>vb(B);
			for(int i=0;i<B;++i)vb[i]=vc[zz++];
			vv.emplace_back(vb);
		}
		while(b--){
			vector<int>vb(B+1);
			for(int i=0;i<B+1;++i)vb[i]=vc[zz++];
			vv.emplace_back(vb);
		}
	}
	return query(vv);
}
int richest(int N,int T,int S){
	if(T==1){
		vector<int>a,b;
		for(int i=1;i<N;++i)for(int j=i+1;j<=N;++j){
			a.emplace_back(i-1);b.emplace_back(j-1);
		}
		vector<int>c=ask(a,b);
		for(int i=0;i<N;++i)cnt[i]=0;
		for(auto z:c)++cnt[z];
		for(int i=0;i<N;++i)if(cnt[i]==N-1)return i;
	}
	tt=0;
	for(int i=0;i<N;++i)vist[i]=0;
	vector<int>vc;
	for(int i=0;i<N;++i)vc.emplace_back(i);
	vc=dd(vc,2);
	vc=dd(vc,2);
	vc=dd(vc,2);
	vc=dd(vc,2);
	vc=dd(vc,-3);
	vc=dd(vc,-6);
	vc=dd(vc,19);
    return query({vc})[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 625ms
memory: 27284kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 3053ms
memory: 125708kb

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: 601ms
memory: 27276kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 3024ms
memory: 126528kb

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