QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500450#9156. 百万富翁IvanZhang2009100 ✓2110ms90980kbC++142.6kb2024-08-01 12:00:152024-08-01 12:00:15

Judging History

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

  • [2024-08-01 12:00:15]
  • 评测
  • 测评结果:100
  • 用时:2110ms
  • 内存:90980kb
  • [2024-08-01 12:00:15]
  • 提交

answer

#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
#define MOD         998244353
#define speMOD      2933256077ll
#define ll          long long
#define pii         pair<int,int>
#define all(v)      v.begin(),v.end()
#define pb          push_back
#define REP(i,b,e)  for(int i=(b);i<(int)(e);++i)
#define over(x)     {cout<<(x)<<endl;return;}
#define lowbit(x)   ((x)&(-(x)))
#define cntbit(x)   __builtin_popcount(x)
#define rf(v)       shuffle(all(v),sd);
#define deal(v)     sort(all(v));v.erase(unique(v.begin(),v.end()),v.end())
#define lbound(v,x) lower_bound(all(v),x)-v.begin()
mt19937 sd(random_device{}());
int T[8]={2,2,2,2,3,6,19,183};
int solve(vector<int>d,int dep){
	if(d.size()==1)return d[0];
	int n=d.size();
	if(dep<4){
		vector<int>a,b;
		REP(i,0,n/2)a.pb(d[i*2]),b.pb(d[i*2+1]);
		return solve(ask(a,b),dep+1);
	}
	if(dep<6){
		vector<int>a,b,c;
		REP(i,0,n/T[dep]){
			int len=T[dep];
			if(i==n/T[dep]-1)++len;
			REP(j,0,len){
				REP(k,j+1,len){
					a.pb(d[i*T[dep]+j]),b.pb(d[i*T[dep]+k]);
				}
			}
		}
		c=ask(a,b);int cur=0;a.clear();
		REP(i,0,n/T[dep]){
			int len=T[dep];
			if(i==n/T[dep]-1)++len;
			vector<int>cnt(len,0);
			REP(j,0,len){
				REP(k,j+1,len){
					if(d[i*T[dep]+j]==c[cur])++cnt[j];else ++cnt[k];
					++cur;
				}
			}
			REP(j,0,len)if(cnt[j]==len-1)a.pb(d[i*T[dep]+j]);
		}
		return solve(a,dep+1);
	}
	if(dep==6){
		vector<int>a,b,c;
		int lft=0;
		REP(i,0,n)if(lft<n){
			int len=T[dep];
			if(i<5)--len;
			REP(j,0,len){
				REP(k,j+1,len){
					a.pb(d[lft+j]),b.pb(d[lft+k]);
				}
			}
			lft+=len;
		}else break;
		c=ask(a,b);int cur=0;a.clear();lft=0;
		REP(i,0,n)if(lft<n){
			int len=T[dep];
			if(i<5)--len;
			vector<int>cnt(len,0);
			REP(j,0,len){
				REP(k,j+1,len){
					if(d[lft+j]==c[cur])++cnt[j];else ++cnt[k];
					++cur;
				}
			}
			REP(j,0,len)if(cnt[j]==len-1)a.pb(d[lft+j]);
			lft+=len;
		}else break;
		return solve(a,dep+1);
	}else{
		vector<int>a,b,c;
		REP(i,0,n){
			REP(j,i+1,n){
				a.pb(d[i]);b.pb(d[j]);
			}
		}
		vector<int>cnt(n,0);
		c=ask(a,b);
		int cur=0;
		REP(i,0,n){
			REP(j,i+1,n){
				if(d[i]==c[cur])++cnt[i];else ++cnt[j];
				++cur;
			}
		}
		REP(i,0,n)if(cnt[i]==n-1)return d[i];
	}
	return -1;
}
int richest(int n,int t,int s){
	t=t;s=s;
	if(n==1000){
		vector<int>a,b,c;
		REP(i,0,n){
			REP(j,i+1,n)a.pb(i),b.pb(j);
		}
		c=ask(a,b);
		vector<int>cnt(n,0);
		for(auto i:c)++cnt[i];
		REP(i,0,n)if(cnt[i]==n-1)return i;
		return -1;
	}
	vector<int>a(n,0);iota(all(a),0);
	return solve(a,0);
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 612ms
memory: 25392kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2048ms
memory: 88332kb

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: 636ms
memory: 25320kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2110ms
memory: 90980kb

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