QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492800#9156. 百万富翁dengziyue100 ✓3024ms209776kbC++142.2kb2024-07-26 16:18:132024-07-26 16:18:13

Judging History

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

  • [2024-07-26 16:18:13]
  • 评测
  • 测评结果:100
  • 用时:3024ms
  • 内存:209776kb
  • [2024-07-26 16:18:13]
  • 提交

answer

#include<bits/stdc++.h>
#include"richest.h"
using namespace std;
vector<int>ask(vector<int>a,vector<int>b);
namespace DZY{
//==========
const int max_n=1000000;
int n;
map<int,int>g[max_n+2];
const int si[12]={0,2,2,2,2,3,6,19,183};
vector<int>now;
vector<int>to;
vector<int>opa,opb;
int ans=0;
vector<int>query(vector<int>a,vector<int>b,bool fl=true){
	vector<int>res=ask(a,b);
	if(fl){
		for(int i=0,len=res.size();i<len;++i)g[a[i]][b[i]]=res[i];
	}
	return res;
}
void askans(){
	for(int i=0;i<=n;++i){g[i].clear(); g[i][i]=i;}
	if(n==1000){
		opa.clear(); opb.clear();
		for(int i=0;i<n;++i){
			for(int j=i+1;j<n;++j){opa.push_back(i); opb.push_back(j);}
		}
		query(opa,opb);
		ans=0;
		for(int i=1;i<n;++i)ans=g[ans][i];
		return;
	}
	now.clear(); to.clear();
	for(int i=0;i<n;++i)now.push_back(i);
	for(int ca=1,len;ca<=8;++ca){
		len=now.size();
		opa.clear(); opb.clear();
		if(ca!=7){
			for(int l=0,r;l<len;l=r+1){
				if(len-l>=si[ca]*2)r=l+si[ca]-1;
				else r=len-1;
				for(int i=l;i<=r;++i){
					for(int j=i+1;j<=r;++j){opa.push_back(now[i]); opb.push_back(now[j]);}
				}
			}
		}
		else{
			for(int ca=0,l,r;ca<5;++ca){
				l=ca*18,r=l+17;
				for(int i=l;i<=r;++i){
					for(int j=i+1;j<=r;++j){opa.push_back(now[i]); opb.push_back(now[j]);}
				}
			}
			for(int ca=0,l,r;ca<178;++ca){
				l=90+ca*19,r=l+18;
				for(int i=l;i<=r;++i){
					for(int j=i+1;j<=r;++j){opa.push_back(now[i]); opb.push_back(now[j]);}
				}
			}
		}
		vector<int>res=query(opa,opb,ca>4);
		to.clear();
		if(ca<=4){
			for(int i=0;i<len;i+=2)to.push_back(res[i/2]);
		}
		else if(ca!=7){
			for(int l=0,r,x;l<len;l=r+1){
				if(len-l>=si[ca]*2)r=l+si[ca]-1;
				else r=len-1;
				x=now[l];
				for(int i=l+1;i<=r;++i)x=g[x][now[i]];
				to.push_back(x);
			}
		}
		else{
			for(int ca=0,l,r,x;ca<5;++ca){
				l=ca*18,r=l+17;
				x=now[l];
				for(int i=l+1;i<=r;++i)x=g[x][now[i]];
				to.push_back(x);
			}
			for(int ca=0,l,r,x;ca<178;++ca){
				l=90+ca*19,r=l+18;
				x=now[l];
				for(int i=l+1;i<=r;++i)x=g[x][now[i]];
				to.push_back(x);
			}
		}
		now=to;
	}
	ans=now[0];
}
//==========
}
int richest(int N,int T,int S){
	DZY::n=N; DZY::askans(); return DZY::ans;
}


Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 922ms
memory: 95660kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 3012ms
memory: 209776kb

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: 937ms
memory: 95340kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

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

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