QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#498271#9156. 百万富翁Hanghang100 ✓2007ms107848kbC++201.4kb2024-07-30 10:55:002024-07-30 10:55:00

Judging History

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

  • [2024-07-30 10:55:00]
  • 评测
  • 测评结果:100
  • 用时:2007ms
  • 内存:107848kb
  • [2024-07-30 10:55:00]
  • 提交

answer

#include"richest.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
typedef vector<int> vi;
const int N=1e6+3;
int n,tot,val[N];
namespace Sub1
{
	int zc[N];
	int Work()
	{
		vi A,B,C;
		for(int i=0;i<n;i++)zc[i]=0;
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)A.pb(i),B.pb(j);
		C=ask(A,B);
		for(int x:C)zc[x]++;
		int s=*max_element(zc,zc+n);
		cerr<<s<<endl;
		return max_element(zc,zc+n)-zc;
	}
};
vi Sol(vi ve,int m)
{
	int i=0,sz=ve.size();vi A,B,C,D,ans;int zz=0;
	for(;i+m<=sz;)
	{
		int st=A.size(),k=m;
		if(sz-i==m+1)k++;
		if(m==19&&++zz<=5)k--;
		for(int x=0;x<k;x++)for(int y=x+1;y<k;y++)A.pb(ve[i+x]),B.pb(ve[i+y]);
		D.pb(A.size()-st);i+=k;
	}
	int st=A.size();
	for(int x=0;x<sz-i;x++)for(int y=x+1;y<sz-i;y++)A.pb(ve[i+x]),B.pb(ve[i+y]);
	if(sz-i)D.pb(A.size()-st);
	C=ask(A,B);tot+=C.size();i=0;
	for(int x:D)
	{
		int mx=0,pos=0;
		for(int j=i;j<i+x;j++)
		{
			val[C[j]]++;
			if(val[C[j]]>mx)mx=val[C[j]],pos=C[j];
		}
		for(int j=i;j<i+x;j++)val[C[j]]=0;
		ans.pb(pos);i+=x;
	}
	return ans;
}
int richest(int _n,int _t,int _s)
{
	tot=0;n=_n;vi ve;
	if(n<=1000)return Sub1::Work();
	for(int i=0;i<n;i++)ve.pb(i);
	ve=Sol(ve,2);
	ve=Sol(ve,2);
	ve=Sol(ve,2);
	ve=Sol(ve,2);
	ve=Sol(ve,3);
	ve=Sol(ve,6);
	ve=Sol(ve,19);
	ve=Sol(ve,ve.size());
	return ve[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 611ms
memory: 27476kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2005ms
memory: 107840kb

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: 607ms
memory: 27360kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2007ms
memory: 107848kb

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