QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#521824 | #9156. 百万富翁 | December456 | 100 ✓ | 1887ms | 106068kb | C++20 | 2.0kb | 2024-08-16 15:31:15 | 2024-08-16 15:31:15 |
Judging History
answer
#include "richest.h"
constexpr int MAXN = 1000000;
constexpr int K[4] = {20832, 3472, 183, 1};
int cnt[MAXN];
void query1(std::vector<int> &q1, std::vector<int> &q2, std::vector<int> vec) {
for (int i = 0; i < vec.size(); i ++) {
for (int j = i + 1; j < vec.size(); j ++) {
q1.push_back(vec[i]);
q2.push_back(vec[j]);
}
cnt[vec[i]] = 0;
}
}
std::vector<int> query2(std::vector<int> vec) {
std::vector<int> v1, v2;
for (int i = 0; i + 1 < vec.size(); i += 2) {
v1.push_back(vec[i]);
v2.push_back(vec[i + 1]);
}
std::vector<int> ret = ask(v1, v2);
if (vec.size() & 1) {
ret.push_back(vec.back());
}
return ret;
}
int richest(int N, int T, int S) {
std::vector<int> cur, res, q1, q2;
for (int i = 0; i < N; i ++) {
cur.push_back(i);
}
if (T == 1) {
query1(q1, q2, cur);
res = ask(q1, q2);
for (int v : res) {
cnt[v] ++;
}
for (int i = 0; i < N; i ++) {
if (cnt[i] == N - 1) {
return i;
}
}
}
for (int i = 0; i < 4; i ++) {
cur = query2(cur);
}
for (int i = 0; i < 4; i ++) {
int k = cur.size() / K[i];
int r = cur.size() % K[i];
std::vector<int> nxt;
q1.clear();
q2.clear();
for (int j = 0, id = 0, len; j < cur.size(); j += len) {
len = k + (id ++ < r);
query1(q1, q2, std::vector<int>(cur.begin() + j, cur.begin() + j + len));
}
res = ask(q1, q2);
for (int v : res) {
cnt[v] ++;
}
for (int j = 0, id = 0, len; j < cur.size(); j += len) {
len = k + (id ++ < r);
for (int x = j; x < j + len; x ++) {
if (cnt[cur[x]] == len - 1) {
nxt.push_back(cur[x]);
}
}
}
cur = nxt;
}
return cur.back();
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 593ms
memory: 25288kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 1875ms
memory: 90496kb
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: 587ms
memory: 25392kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 1887ms
memory: 106068kb
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