QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492777#9156. 百万富翁Erinyes100 ✓4755ms105388kbC++141.7kb2024-07-26 15:59:552024-07-26 15:59:55

Judging History

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

  • [2024-07-26 15:59:55]
  • 评测
  • 测评结果:100
  • 用时:4755ms
  • 内存:105388kb
  • [2024-07-26 15:59:55]
  • 提交

answer

#include<bits/stdc++.h>
#include "richest.h"
using namespace std;
int id[1005][1005],ins[1000005];
map<pair<int,int>,int>g;
int cnt,sum;
// vector<int> ask(vector<int>a,vector<int>b){
// 	cnt++,sum+=a.size();
// 	for(int i=0;i<a.size();i++){
// 		cout<<a[i]<<' '<<b[i]<<endl;
// 	}
// 	vector<int>c;
// 	for(int i=0;i<a.size();i++){
// 		int k;cin>>k;
// 		c.push_back(k);
// 	}return c;
// }
inline vector<int> jqh(vector<int> d,int k){
	vector<int>A,B,C;g.clear();
	int len=d.size()/k;
	for(int i=0,j=1;i<d.size();j++){
		int L=len+(j<=d.size()%k);
		for(int a=i;a<i+L;a++){
			for(int b=a+1;b<i+L;b++){
				g[{a,b}]=A.size();
				A.push_back(d[a]),B.push_back(d[b]);
			}
		}i+=L;
	}
	C=ask(A,B);
	vector<int>D;
	for(int i=0,j=1;i<d.size();j++){
		int L=len+(j<=d.size()%k);
		for(int a=i;a<i+L;a++){
			bool tag=1;
			for(int b=i;b<a;b++)if(C[g[{b,a}]]!=d[a]){tag=0;break;}
			for(int b=a+1;b<i+L;b++)if(C[g[{a,b}]]!=d[a]){tag=0;break;}
			if(tag){D.push_back(d[a]);break;}
		}i+=L;
	}
	return D;
}
int richest(int n, int T, int S){
	if(n==1000){
		vector<int>A,B;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				id[i][j]=A.size(),A.push_back(i),B.push_back(j);
			}
		}
		auto C=ask(A,B);
		for(int i=0;i<n;i++){
			bool tag=1;
			for(int j=0;j<i;j++)if(C[id[j][i]]!=i)tag=0;
			for(int j=i+1;j<n;j++)if(C[id[i][j]]!=i)tag=0;
			if(tag)return i;
		}
	}
	vector<int>d;
	for(int i=0;i<n;i++)d.push_back(i);
	d=jqh(d,500000);
	d=jqh(d,250000);
	d=jqh(d,125000);
	d=jqh(d,62500);
	d=jqh(d,20833);
	d=jqh(d,3472);
	d=jqh(d,183);
	d=jqh(d,1);
	return d.front();
}
// int main(){
// 	cout<<richest(5,10,114514)<<endl;
// 	cout<<cnt<<' '<<sum<<endl;
// }

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 603ms
memory: 32884kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 4736ms
memory: 104360kb

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: 619ms
memory: 31924kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 4755ms
memory: 105388kb

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