QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#601979 | #9156. 百万富翁 | Hunster# | 100 ✓ | 2252ms | 93728kb | C++20 | 1.2kb | 2024-09-30 17:14:33 | 2024-09-30 17:14:33 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
constexpr int table[] = {1000000, 500000, 250000, 125000, 62500, 20832, 3472, 183, 1};
constexpr int N = 1000006;
int cnt[N];
std::vector<int> a, b, c;
void query(std::vector<int> vec) {
for (int i = 0; i < vec.size(); i++)
for (int j = i + 1; j < vec.size(); j++) {
a.push_back(vec[i]);
b.push_back(vec[j]);
}
}
int richest(int n, int t, int s) {
std::fill_n(cnt, n, 0);
std::vector<int> all(n);
std::iota(all.begin(), all.end(), 0);
const auto work = [&](int len) {
int t = all.size() / len, w = all.size() % len;
a.clear();
b.clear();
for (int i = 0, l = 0, r; i < len; i++, l = r) {
r = l + t + (i < w);
query(std::vector<int>(all.begin() + l, all.begin() + r));
}
c = ask(a, b);
for (int i = 0; i < a.size(); i++) cnt[a[i] ^ b[i] ^ c[i]]++;
std::vector<int> _all;
for (int x : all) if (!cnt[x]) _all.push_back(x);
std::swap(all, _all);
};
if (n == 1000) work(1);
else for (int i = 1; i <= 8; i++) work(table[i]);
return all[0];
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 619ms
memory: 26292kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2252ms
memory: 93712kb
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: 618ms
memory: 26304kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2228ms
memory: 93728kb
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