QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513268#9156. 百万富翁Line1215 624ms94732kbC++141.6kb2024-08-10 17:22:342024-08-10 17:22:35

Judging History

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

  • [2024-08-10 17:22:35]
  • 评测
  • 测评结果:15
  • 用时:624ms
  • 内存:94732kb
  • [2024-08-10 17:22:34]
  • 提交

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=1;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;
//}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 617ms
memory: 34500kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 581ms
memory: 94732kb

input:

1000000 20 2000000 29091473

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer


Final Tests

Test #1:

score: 15
Accepted
time: 624ms
memory: 32720kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 356ms
memory: 94140kb

input:

1000000 20 2000000 29091471

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer