QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493214 | #9156. 百万富翁 | zhouyuhang | 100 ✓ | 2001ms | 102156kb | C++14 | 1.2kb | 2024-07-26 21:53:07 | 2024-07-26 21:53:07 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
using vint = vector<int>;
const int B[10] = {0, 500000, 250000, 125000, 62500, 20833, 3472, 183};
int solve(vint v, int N) {
vint a, b;
for (int i = 1; i < v.size(); ++i) {
for (int j = 0; j < i; ++j) {
a.push_back(v[i]), b.push_back(v[j]);
}
}
vint c = ask(a, b), cnt(N);
for (auto &u: c) cnt[u]++;
for (auto &u: v) if (cnt[u] == (int)v.size() - 1) return u;
return -1;
}
int richest(int N, int T, int S) {
if (N <= 1000) {
vint v(N);
for (int i = 0; i < N; ++i) v[i] = i;
return solve(v, N);
}
vint v(N);
for (int i = 0; i < N; ++i) v[i] = i;
int k = 1;
while (k <= 7) {
vint len(B[k], v.size() / B[k]);
for (int i = 0; i < v.size() % B[k]; ++i) len[i]++;
vint a, b;
for (int i = 0, l = 0, r; i < B[k]; ++i, l = r + 1) {
r = l + len[i] - 1;
for (int j = l + 1; j <= r; ++j) {
for (int k = l; k < j; ++k) {
a.push_back(v[j]), b.push_back(v[k]);
}
}
}
vint c = ask(a, b), cnt(N);
for (int i = 0; i < c.size(); ++i) cnt[a[i] ^ b[i] ^ c[i]]++;
vint nv;
for (auto &u: v) if (!cnt[u]) nv.push_back(u);
++k, swap(v, nv);
}
return solve(v, N);
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 615ms
memory: 22384kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 1986ms
memory: 102156kb
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: 616ms
memory: 24312kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2001ms
memory: 102092kb
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