QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721738#9156. 百万富翁Azusa91.00003 2641ms92244kbC++142.0kb2024-11-07 16:43:292024-11-07 16:43:29

Judging History

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

  • [2024-11-07 16:43:29]
  • 评测
  • 测评结果:91.00003
  • 用时:2641ms
  • 内存:92244kb
  • [2024-11-07 16:43:29]
  • 提交

answer

#include "richest.h"
#include<bits/stdc++.h>
 
using namespace std;
 
std::vector <int> ask(std::vector <int> a, std::vector <int> b);

namespace sub1{
	const int maxn=1010;
	int id[maxn];
	bool win[maxn][maxn];

	inline int sol(int n){
		vector<int> a,b,c;
		for(int i=0;i<n;i++) id[i]=i;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				win[i][j]=false;
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++){
				a.push_back(i);
				b.push_back(j);
			} 
		c=ask(a,b);
		for(int i=0;i<a.size();i++){
			int x=a[i],y=b[i],z=c[i];
			if(z==x) win[x][y]=true;
			else win[y][x]=true;
		} 
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++)
				if(win[id[i]][id[j]]) swap(id[i],id[j]);  
		return id[n-1];		
	}
}

namespace sub2{
	const int maxn=1e6+10;

	int id[maxn];
	map<pair<int,int>,bool> win;

	inline void merge(vector<int> &vec,int k){
		int sz=vec.size(),cnt,idx=0;
		cnt=sz%k;
		vector<int> a,b,c,t;
		for(int i=k-1,j=0;i<sz;i+=k){
			if(cnt){
				cnt--;
				i++;
			}
			for(int l=j;l<=i;l++)
				for(int r=l+1;r<=i;r++){
					a.push_back(vec[l]);
					b.push_back(vec[r]);
				}
			j=i+1;
		}
		cnt=sz%k;
		c=ask(a,b);
		for(int i=k-1,j=0;i<sz;i+=k){
			if(cnt){
				cnt--;
				i++;
			}
			for(int w=j;w<=i;w++) id[w]=w;
			win.clear();
			for(int l=j;l<=i;l++){
				for(int r=l+1;r<=i;r++){
					int nw=idx+(r-(l+1));
					int x=a[nw],y=b[nw],z=c[nw];
					if(z==x) win[{x,y}]=true;
					else win[{y,x}]=true;
				}
				idx+=i-(l+1)+1;
			}
			for(int l=j;l<=i;l++)
				for(int r=l+1;r<=i;r++)
					if(win[{vec[id[l]],vec[id[r]]}]) swap(id[l],id[r]); 
			t.push_back(vec[id[i]]);
			j=i+1;
		}
		vec.swap(t);
	}

	inline int sol(int n){
		vector<int> vec;
		for(int i=0;i<n;i++) vec.push_back(i);
		for(int i=4;i--;) merge(vec,2);
		merge(vec,3); merge(vec,6); merge(vec,19); 
		merge(vec,182);
		return vec.back();
	}
}

int richest(int N, int T, int S) {
	if(N<=1000) return sub1::sol(N);
	else return sub2::sol(N);
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 625ms
memory: 28480kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 76
Acceptable Answer
time: 2594ms
memory: 92244kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947


Final Tests

Test #1:

score: 15
Accepted
time: 627ms
memory: 30044kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 76
Acceptable Answer
time: 2641ms
memory: 92112kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947