QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#740355#9156. 百万富翁Sai_tqwq100 ✓5392ms147512kbC++141.5kb2024-11-13 09:19:222024-11-13 09:19:23

Judging History

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

  • [2024-11-13 09:19:23]
  • 评测
  • 测评结果:100
  • 用时:5392ms
  • 内存:147512kb
  • [2024-11-13 09:19:22]
  • 提交

answer

#include<bits/stdc++.h>
 #include "richest.h"
using namespace std;
#define endl '\n'
const int cut[]={500000, 250000, 125000, 62500, 20832, 3472, 183, 1};
map<pair<int,int>,int> id;
int richest(int n,int t,int s){
	id.clear();
	if(n==1000){
		vector<int> a,b;
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++)
				a.push_back(i),b.push_back(j),id[{i,j}]=(int)a.size()-1;
		auto p=ask(a,b);
		for(int i=0;i<n;i++){
			bool fl=1;
			for(int j=0;j<n;j++)if(i!=j&&p[id[{min(i,j),max(i,j)}]]!=i){
				fl=0;
				break;
			}
			if(fl)return i;
		}
	}
	vector<int> cur;
	for(int i=0;i<n;i++)cur.push_back(i);
	for(int p=0;p<8;p++){
		vector<int> a,b,tmp;
		int s=(int)cur.size()/cut[p],bmod=(int)cur.size()%cut[p],amod=cut[p]-bmod;
		int top=0;
		for(int i=0;i<amod;i++){
			for(int j=top;j<top+s;j++)
				for(int k=j+1;k<top+s;k++)
					a.push_back(cur[j]),b.push_back(cur[k]),id[{cur[j],cur[k]}]=(int)a.size()-1;
			top+=s;
		}
		for(int i=0;i<bmod;i++){
			for(int j=top;j<=top+s;j++)
				for(int k=j+1;k<=top+s;k++)
					a.push_back(cur[j]),b.push_back(cur[k]),id[{cur[j],cur[k]}]=(int)a.size()-1;
			top+=s+1;
		}
		auto c=ask(a,b);top=0;
		for(int i=0;i<amod;i++){
			int sp=top;
			for(int j=top+1;j<top+s;j++)
				if(c[id[{cur[sp],cur[j]}]]==cur[j])sp=j;
			tmp.push_back(cur[sp]);
			top+=s;
		}
		for(int i=0;i<bmod;i++){
			int sp=top;
			for(int j=top+1;j<=top+s;j++)
				if(c[id[{cur[sp],cur[j]}]]==cur[j])sp=j;
			tmp.push_back(cur[sp]);
			top+=s+1;
		}
		cur=tmp;
	}
	return cur[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 1644ms
memory: 52248kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 5367ms
memory: 147484kb

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: 1659ms
memory: 52492kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 5392ms
memory: 147512kb

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