QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#509014 | #9156. 百万富翁 | Qwerty1232# | 15 | 757ms | 23104kb | C++23 | 1.6kb | 2024-08-08 02:22:09 | 2024-08-08 02:22:10 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
const std::string precalc_str_data = R"(
15
1 2 1 -1 -1
1 3 3 -1 -1
1 4 6 -1 -1
1 6 15 -1 -1
1 18 153 -1 -1
1 19 171 -1 -1
1 183 16653 -1 -1
2 4 3 2 1
2 18 33 6 1
2 19 36 6 1
2 3472 47856 183 1
3 8 7 2 1
4 16 15 2 1
4 62500 162444 3472 2
8 1000000 1099944 62500 4
)";
std::vector<int> select_multi(int t, std::vector<std::vector<int>> vec) {
if (t == 1) {
std::vector<int> a, b;
for (int i = 0; i < vec.size(); i++) {
auto& vc = vec[i];
for (int i = 0; i < vc.size(); i++) {
for (int j = i + 1; j < vc.size(); j++) {
a.push_back(vc[i]);
b.push_back(vc[j]);
}
}
}
std::vector<int> c = ask(a, b);
std::sort(c.begin(), c.end());
auto count = [&](int val) {
auto [it1, it2] = std::equal_range(c.begin(), c.end(), val);
return it2 - it1;
};
std::vector<int> ans(vec.size());
for (int i = 0; i < vec.size(); i++) {
ans[i] = vec[i].front();
for (int j : vec[i]) {
if (count(j) > count(ans[i])) {
ans[i] = j;
}
}
}
return ans;
}
assert(false);
}
int richest(int n, int t, int s) {
t = std::min(t, 8);
std::vector<int> all(n);
std::iota(all.begin(), all.end(), 0);
auto ans = select_multi(t, {all});
assert(ans.size() == 1);
return ans.front();
}
// 100 1 100000 5
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 757ms
memory: 21100kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 749ms
memory: 23104kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091471
output:
Unauthorized output