QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513372#9156. 百万富翁Line12100 ✓2074ms103252kbC++141.6kb2024-08-10 17:39:382024-08-10 17:39:39

Judging History

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

  • [2024-08-10 17:39:39]
  • 评测
  • 测评结果:100
  • 用时:2074ms
  • 内存:103252kb
  • [2024-08-10 17:39:38]
  • 提交

answer

#include<bits/stdc++.h>
#include "richest.h"
using namespace std;
const int N=1000009;
int w[N],n,p[N],deg[N],m,q[N],sum;
vector<int> a,b,c;
//vector<int> ask(vector<int> a,vector<int> b){
//	vector<int> c;
//	for(int i=0;i<a.size();i++)
//	    if(w[a[i]]>w[b[i]])c.push_back(a[i]);
//	    else c.push_back(b[i]);
//	return c;
//}
void solve(int x){
	a.clear();
	b.clear();
	int t=n/x;
	int l=0,r=0;
	for(int i=1;i<=x-n%x;i++){
		l=r+1;
		r=l+t-1;
		for(int j=l;j<=r-1;j++)
		    for(int k=j+1;k<=r;k++){
		    	a.push_back(p[j]);
		    	b.push_back(p[k]);
			}
	}
	for(int i=1;i<=n%x;i++){
		l=r+1;
		r=l+t;
		for(int j=l;j<=r-1;j++)
		    for(int k=j+1;k<=r;k++){
		    	a.push_back(p[j]);
		    	b.push_back(p[k]);
			}
	}
	c=ask(a,b);
	int tmp=0;
	for(int i=0;i<=1000000;i++)
	    deg[i]=0;
	for(int i=0;i<c.size();i++){
		if(a[i]==c[i])deg[b[i]]++;
		else deg[a[i]]++;
	}
	m=0;
	for(int i=1;i<=n;i++){
		if(deg[p[i]]!=0)continue;
		q[++m]=p[i];
	}
	n=m;
	for(int i=1;i<=n;i++)
	    p[i]=q[i];
	sum+=c.size();
}
int richest(int N,int T,int S){
	n=N;
	for(int i=1;i<=n;i++)
	    p[i]=i-1;
	if(n==1000)
		solve(1);
	else{
		solve(500000);
		solve(250000);
		solve(125000);
		solve(62496);
		solve(20832);
		solve(3472);
		solve(183);
		solve(1);
	}
	return p[1];
}
//int main(){
//	n=1000000;
//	mt19937 rnd(time(0));
//	for(int i=1;i<=n;i++)
//	    w[i-1]=rnd()/4;
//	printf("%d ",richest(n,10000000,10000000));
//	int fnd=0;
//	for(int i=1;i<=1000000-1;i++)
//	    if(w[i]>w[fnd])fnd=i;
//	printf("%d %d",fnd,sum);
//	return 0;
//}

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 628ms
memory: 34540kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2063ms
memory: 102444kb

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: 629ms
memory: 32696kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2074ms
memory: 103252kb

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