QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492314#9156. 百万富翁leihonglongyin#50.999965 3300ms95728kbC++142.0kb2024-07-26 11:21:462024-07-26 11:21:48

Judging History

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

  • [2024-07-26 11:21:48]
  • 评测
  • 测评结果:50.999965
  • 用时:3300ms
  • 内存:95728kb
  • [2024-07-26 11:21:46]
  • 提交

answer

#include "richest.h"
#include<bits/stdc++.h>
using namespace std;mt19937 R(time(0));
vector<int>now,a,b,tmp,to;map<int,int>cnt;int tot;
void sol0(){cnt.clear(),a.clear(),b.clear(),tot++;int len=now.size();
	for(int i=0;i<len;i++)for(int j=i+1;j<len;j++)
		a.push_back(now[i]),b.push_back(now[j]);
	tmp=ask(a,b),now.resize(1);for(auto i:tmp)cnt[i]++;
	for(auto i:cnt)if(i.second==len-1)return now[0]=i.first,void();
}
void sol1(int len){
	while(now.size()>len){a.clear(),b.clear();int lst=0;
		shuffle(now.begin(),now.end(),R),tot++;
		for(int i=0;i+1<now.size();i+=2)a.push_back(now[i]),b.push_back(now[i+1]);
		if(now.size()&1)lst=now.back();
		now=ask(a,b);if(lst)now.push_back(lst);
	}
}
void sol2(int len){
	while(now.size()>len){a.clear(),b.clear(),tmp.clear(),to.clear();
    	shuffle(now.begin(),now.end(),R),tot++;
		for(int i=0;i+1<now.size();i++)a.push_back(now[i]),b.push_back(now[i+1]);
		a.push_back(now[0]),b.push_back(now.back()),tmp=ask(a,b);
		for(int i=0;i<now.size();i++){
			if(tmp[i?i-1:now.size()-1]==tmp[i]&&tmp[i]==now[i])to.push_back(now[i]);
		}now=to;
	}
}
void sol3(int len){
	while(now.size()>len){a.clear(),b.clear(),tmp.clear(),to.clear();
    	shuffle(now.begin(),now.end(),R),tot++;
    	int len=sqrt(now.size());if(len==1)len++;
		vector<int>id(now.size());
    	for(int i=0;i<now.size();i++)id[i]=i/len+1;
    	for(int i=0;i<=id.back();i++){
    		int l=i*len,r=min(i*len+len,(int)now.size())-1; 
			for(int x=l;x<=r;x++)for(int y=x+1;y<=r;y++)
				a.push_back(now[x]),b.push_back(now[y]);
		}tmp=ask(a,b);int num=0;
		for(int i=0;i<=id.back();i++){cnt.clear();
    		int l=i*len,r=min(i*len+len,(int)now.size())-1; 
			for(int x=l;x<=r;x++)for(int y=x+1;y<=r;y++)
				cnt[tmp[num++]]++;
			for(int j=l;j<=r;j++)if(cnt[now[j]]==r-l)to.push_back(now[j]);
		}now=to;
	}
}
int richest(int N,int T,int S){now.clear(),tot=0;
	if(T==1){for(int i=0;i<N;i++)now.push_back(i);return sol0(),now[0];}
	for(int i=0;i<N;i++)now.push_back(i);
	sol1(1e5);
    sol2(5e3);
	sol3(500);
	sol0();
	return now[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 743ms
memory: 24596kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 36
Acceptable Answer
time: 3282ms
memory: 95648kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 36 / 85, maxt = 9, maxs = 1119364
6340914393631587735
0.423529
5328301984933965793

result:

points 0.423529 Partially correct Case 2, 36 / 85, maxt = 9, maxs = 1119364


Final Tests

Test #1:

score: 15
Accepted
time: 750ms
memory: 22656kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 36
Acceptable Answer
time: 3300ms
memory: 95728kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 36 / 85, maxt = 9, maxs = 1119367
16997220722950055677
0.423529
5328301984933965793

result:

points 0.423529 Partially correct Case 2, 36 / 85, maxt = 9, maxs = 1119367