QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499285#9156. 百万富翁tanxi#100 ✓2636ms109904kbC++142.4kb2024-07-31 11:19:382024-07-31 11:19:38

Judging History

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

  • [2024-07-31 11:19:38]
  • 评测
  • 测评结果:100
  • 用时:2636ms
  • 内存:109904kb
  • [2024-07-31 11:19:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
std::vector<int> ask(std::vector<int> a, std::vector<int> b);
int richest(int N, int T, int S)
{
	vector<int>now,v;
	now.clear();v.clear();
	v.resize(N+1,0);
	for(int i=1;i<=N;i++)
	now.push_back(i);
	if(T==1)
	{
		vector<int>a,b;
		a.clear(),b.clear();
		for(int i=0;i<now.size();i++)
		{
			for(int j=i+1;j<now.size();j++)
			{
				a.push_back(now[i]-1);
				b.push_back(now[j]-1);
			}
		}
		vector<int> c=ask(a,b);
		for(int i=0;i<c.size();i++)
		{
			v[(a[i]^b[i]^c[i])+1]=1;
		}
		for(int i=1;i<=N;i++)
		if(!v[i])
		{
			return i-1;
		}
	}
	int siz[8]={0,500000,250000,125000,62496,20832,3472,183};
	/*
	1099944 1000000
	599944 500000
	349944 250000
	224944 125000
	162432 62496
	99936 20832
	47856 3472
	16653 183
	0 1
	*/
	for(int p=1;p<=7;p++)
	{
		int k=now.size()/siz[p];
		int num=now.size()%siz[p];
		vector<vector<int> >tp;
		tp.clear();
		for(int i=1;i<=siz[p];i++)
		{
			tp.push_back({});
		}
		int lst=0;
		int tnum=0;
		for(int t=0;t/k<siz[p];t+=k)
		{
			tnum++;
			lst=t+k-1;
			for(int j=0;j<k;j++)
			tp[t/k].push_back(now[t+j]);
		}
		// cerr<<now.size()<<' '<<lst+1<<' '<<siz[p]*k<<' '<<siz[p]<<' '<<tnum<<' '<<k<<' '<<tp[siz[p]-1].size()<<'\n';
		for(int j=lst+1;j<now.size();j++)
		{
			// cerr<<j-lst-1<<' '<<siz[p]<<endl;
			tp[j-lst-1].push_back(now[j]);
		}
		vector<int>a;
		vector<int>b;
		a.clear();
		b.clear();
		int tt=0;
		for(int t=0;t<siz[p];t++)
		{
			for(int i=0;i<tp[t].size();i++)
			for(int j=i+1;j<tp[t].size();j++)
			{
				a.push_back(tp[t][i]-1);
				b.push_back(tp[t][j]-1);
			}
			if(tp[t].size()>k)
			tt++;
		}
		vector<int>c=ask(a,b);
		for(int i=0;i<c.size();i++)
		{
			v[(a[i]^b[i]^c[i])+1]=1;
		}
		// cerr<<tt<<' '<<num<<'\n';
		vector<int>newn;
		newn.clear();
		for(auto u:now)
		{
			if(!v[u])
			newn.push_back(u);
		}
		now.clear();
		swap(now,newn);
	}
	vector<int>a,b;
	a.clear(),b.clear();
	for(int i=0;i<now.size();i++)
	{
		for(int j=i+1;j<now.size();j++)
		{
			a.push_back(now[i]-1);
			b.push_back(now[j]-1);
		}
	}
	vector<int> c=ask(a,b);
	for(int i=0;i<c.size();i++)
	{
		v[(a[i]^b[i]^c[i])+1]=1;
	}
	// cerr<<c.size()<<'\n';
	for(int i=1;i<=N;i++)
	if(!v[i])
	{
		return i-1;
	}
}
/*


1099944 1000000
599944 500000
349944 250000
224944 125000
162432 62496
99936 20832
47856 3472
16653 183
0 1



*/

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 618ms
memory: 25316kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2636ms
memory: 102016kb

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: 616ms
memory: 23440kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2606ms
memory: 109904kb

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