QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#509732#9156. 百万富翁Arapak#23.99997 3543ms125460kbC++202.1kb2024-08-08 18:01:362024-08-08 18:01:36

Judging History

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

  • [2024-08-08 18:01:36]
  • 评测
  • 测评结果:23.99997
  • 用时:3543ms
  • 内存:125460kb
  • [2024-08-08 18:01:36]
  • 提交

answer

#include "bits/stdc++.h"
#include "richest.h"
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#ifdef DEBUG
auto& operator<<(auto& os, const pair<auto,auto> &p) {
	return os<<"("<<p.first<<", "<<p.second<<")";
}

auto& operator<<(auto& os, const auto &v) {
	os<<"{";
	for(auto it=begin(v);it!=v.end();++it) {
		if(it!=begin(v)) os<<", ";
		os<<(*it);
	}
	return os<<"}";
}

void dbg_out(auto... x) {
	((cerr<<' '<<x), ...) << endl;
}

#define dbg(x...) cerr<<"("<<#x<<"):", dbg_out(x);
#else
#define dbg(...)
#endif

int solve(vector<int> ind) {
	dbg(ind);
	int n = sz(ind);
	vector<pii> q;
	for(int i=0;i<n;i+=3) {
		if(i+3<=n) {
			q.emplace_back(i, i+1);
			q.emplace_back(i, i+2);
			q.emplace_back(i+1, i+2);
		}
		else if(i+2<=n) 
			q.emplace_back(i, i+1);
	}
	vi a, b;
	for(auto [x, y] : q) {
		a.push_back(ind[x]);
		b.push_back(ind[y]);
	}
	dbg(a, b);
	vi res = ask(a, b);
	dbg(res);
	vi new_ind;
	for(int i=0;i<n;i+=3) {
		if(i+3<=n) {
			auto check = [&](const int index) {
				int num = 0;
				num += res[i] == ind[index];
				num += res[i+1] == ind[index];
				num += res[i+2] == ind[index];
				return num == 2;
			};
			if(check(i)) new_ind.push_back(ind[i]);
			else if(check(i+1)) new_ind.push_back(ind[i+1]);
			else new_ind.push_back(ind[i+2]);
		}
		else if(i+2<=n) 
			new_ind.push_back(res[i]);
		else
			new_ind.push_back(ind[i]);
	}
	// for(auto &x : new_ind)
	// 	x = ind[x];
	dbg(new_ind);
	if(sz(new_ind) == 1) return new_ind[0];
	return solve(new_ind);
}

int richest(int N, int T, int S) {
	if(T == 1) {
		vi a, b;
		rep(i,0,N) rep(j,i+1,N) {
			a.push_back(i);
			b.push_back(j);
		}
		auto res = ask(a, b);
		sort(all(res));
		int prev = -1;
		int num = 0;
		for(auto x : res) {
			if(x == prev) {
				num++;
				if(num == N-1) return x;
			}
			else {
				prev = x;
				num = 1;
			}
		}
		assert(false);
	}
    vi perm(N);
    iota(all(perm), 0);
    return solve(perm);
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 746ms
memory: 25352kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 8.99997
Acceptable Answer
time: 3543ms
memory: 124132kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997
7616820272462450011
0.105882
16926627793318235567

result:

points 0.105882 Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997


Final Tests

Test #1:

score: 15
Accepted
time: 742ms
memory: 25372kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 8.99997
Acceptable Answer
time: 3509ms
memory: 125460kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997
7616820272462450011
0.105882
16926627793318235567

result:

points 0.105882 Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997