QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#492353#9156. 百万富翁Augenstern#0 71ms238124kbC++142.5kb2024-07-26 11:35:392024-07-26 11:35:40

Judging History

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

  • [2024-07-26 11:35:40]
  • 评测
  • 测评结果:0
  • 用时:71ms
  • 内存:238124kb
  • [2024-07-26 11:35:39]
  • 提交

answer

#include "richest.h"
#include<bits/stdc++.h>
//#define int long long
//#define ull unsigned int
//#define lll __int128
//#define double long double
using namespace std;
const long long INF=1e9+5;
//const long long mod=998244353,orm=3;
const long long mod=1000000007;
const int MAXN=1000005;
const double eps=1e-6;
vector<pair<int,int> > v2[MAXN],v[MAXN];
vector<int> A,B,ans,v3[MAXN];
int N,B1=2,B2=1000,B3=10,rt=0,tot=0;
int d[MAXN],be[MAXN],vis[MAXN];
int son[MAXN][22];
void calc(int dep,int &k,int l,int r) {
	if(!k) k=++tot,d[k]=dep;
	int len=r-l+1;
	if(len==1) {
		be[k]=l;
		return ;
	}
	if(len<=B1) {
		for(int i=l;i<=r;i++) {
			for(int j=i+1;j<=r;j++) v[k].push_back({i,j});
		}
		return ;
	}
	if(len>=B2) {
		int sz=len/B3;
		for(int i=1;i<B3;i++) {
			calc(dep+1,son[k][++son[k][0]],l,l+sz-1);l+=sz;
		}
		if(l<=r) calc(dep+1,son[k][++son[k][0]],l,r);
		for(int i=1;i<=son[k][0];i++) {
			for(int j=i+1;j<=son[k][0];j++) {
				v2[k].push_back({son[k][i],son[k][j]});
			}
		}
		return ;
	}
	int sz=len/B1;
	for(int i=1;i<B1;i++) {
		calc(dep+1,son[k][++son[k][0]],l,l+sz-1);l+=sz;
	}
	if(l<=r) calc(dep+1,son[k][++son[k][0]],l,r);
	for(int i=1;i<=son[k][0];i++) {
		for(int j=i+1;j<=son[k][0];j++) {
			v2[k].push_back({son[k][i],son[k][j]});
		}
	}
}
void clear() {
	A.clear(),B.clear(),ans.clear();
}
void Clear() {
	rt=0;
	for(int i=1;i<=tot;i++) {
		son[i][0]=d[i]=be[i]=vis[i]=0;
		v[i].clear(),v2[i].clear(),v3[i].clear();
	}
	tot=0;
}
int richest(int N, int T, int S) {
	calc(0,rt,1,N);
	for(int i=1;i<=tot;i++) {
		for(auto p:v[i]) {
			A.push_back(p.first),B.push_back(p.second);
		}
	}
	ans=ask(A,B);int nw=0;
	for(int i=1;i<=tot;i++) {
		int id=0;
		for(auto p:v[i]) {
			if(ans[nw++]==p.first) vis[p.second]=1;
			else vis[p.first]=1;
		}
		for(auto p:v[i]) {
			if(!vis[p.first]) id=p.first;
			if(!vis[p.second]) id=p.second;
		}
		be[i]=id;
	}
	clear();nw=0;
	int mx=0;
	for(int i=1;i<=tot;i++) v3[d[i]].push_back(i),mx=max(mx,d[i]);
	for(int i=mx;i>=0;i--) {
		for(int j:v3[i]) {
			for(auto p:v2[j]) {
				if(!be[p.first]||!be[p.second]) assert(0);
				A.push_back(be[p.first]),B.push_back(be[p.second]);
			}
		}
		ans=ask(A,B);nw=0;
		for(int j:v3[i]) {
			for(auto p:v2[j]) {
				if(ans[nw++]==be[p.first]) vis[be[p.second]]=1;
				else vis[be[p.first]]=1;
			}
			int id=0;
			for(auto p:v2[j]) {
				if(!vis[be[p.first]]) id=be[p.first];
				if(!vis[be[p.second]]) id=be[p.second];
			}
			be[j]=id;
		}
		clear();nw=0;
	}
	int res=be[rt];Clear();
    return res;
}

詳細信息


Pretests

Pretest #1:

score: 0
Wrong Answer
time: 22ms
memory: 84672kb

input:

1000 1 499500 957319859

output:

Index out of bounds
9775460264716263939
0.000000
6906350380861515327

result:

points 0.0 Index out of bounds

Pretest #2:

score: 0
Wrong Answer
time: 71ms
memory: 237424kb

input:

1000000 20 2000000 29091473

output:

Index out of bounds
9775460264716263939
0.000000
6906350380861515327

result:

points 0.0 Index out of bounds


Final Tests

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 85592kb

input:

1000 1 499500 957319857

output:

Index out of bounds
9775460264716263939
0.000000
6906350380861515327

result:

points 0.0 Index out of bounds

Test #2:

score: 0
Wrong Answer
time: 67ms
memory: 238124kb

input:

1000000 20 2000000 29091471

output:

Index out of bounds
9775460264716263939
0.000000
6906350380861515327

result:

points 0.0 Index out of bounds