QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#490137#9156. 百万富翁strcmp#26.00002 2322ms98532kbC++141.6kb2024-07-25 11:43:172024-07-25 11:43:17

Judging History

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

  • [2024-07-25 11:43:17]
  • 评测
  • 测评结果:26.00002
  • 用时:2322ms
  • 内存:98532kb
  • [2024-07-25 11:43:17]
  • 提交

answer

#include <bits/stdc++.h>
//#include <windows.h>
using namespace std;
#include "richest.h"
#define rep(i, a, b) for(int i = a; i <= b; i++)
using vec = vector<int>;
using ll = long long int;
constexpr int maxn = 2e6 + 10;
#define ps push_back
vec p, np, a, b; int n, t, s, cnt[maxn];
int qry(int l, int r) {
	if (l == r) return p[l];
	a.clear(); b.clear();
	for (int i = l; i < r; i++) {
		for (int j = i + 1; j <= r; j++) a.ps(p[i]), b.ps(p[j]); 
	}
	vec c = ask(a, b); int ans = 0;
	for (int i = 0; i < c.size(); i++) {
		++cnt[c[i]];
		if (cnt[c[i]] == r - l) ans = c[i];
	}
	for (int i = 0; i < c.size(); i++) --cnt[c[i]];
	a.clear(); b.clear();
	return ans;
}
void qwq(int l, int r) {
	for (int i = l; i < r; i++) {
		for (int j = i + 1; j <= r; j++) a.ps(p[i]), b.ps(p[j]); 
	}
}
void divide(int k) {
	for (int i = 0; i < n; i += k) {
		int j = min(i + k - 1, n - 1);
		qwq(i, j);
	}
	vec c = ask(a, b); int L = 0;
	for (int i = 0; i < n; i += k) {
		int j = min(i + k - 1, n - 1);
		int len = j - i + 1;
		if (len == 1) { np.ps(p[i]); continue; }
		int wx = len * (len - 1) / 2;
		int R = L + wx - 1, ans = p[i];
		for (int k = L; k <= R; k++) {
			++cnt[c[k]];
			if (cnt[c[k]] == len - 1) ans = c[k];
		}
		for (int k = L; k <= R; k++) --cnt[c[k]];
		np.ps(ans); L = R + 1;
	}
	p = np; n = p.size(); np.clear(); a.clear(); b.clear(); 
}
int richest(int N, int T, int S) {
	n = N, t = T, s = S; p.clear(); np.clear();
	for (int i = 0; i < n; i++) p.ps(i);
	for (int i = 1; i < t; i++) if (n >= 2) divide(2);
	//for (int i = 0; i < n; i++) cerr << p[i] << " "; cerr << "\n";
	//Sleep(5000);
	return qry(0, n - 1);
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 626ms
memory: 22680kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 11
Acceptable Answer
time: 2322ms
memory: 97304kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999
1811468636458994965
0.129412
3823502568050958645

result:

points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999


Final Tests

Test #1:

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

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 11
Acceptable Answer
time: 2317ms
memory: 98532kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999
1811468636458994965
0.129412
3823502568050958645

result:

points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999