QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#488071 | #9156. 百万富翁 | Xiaohuba | 100 ✓ | 2248ms | 90352kb | C++23 | 2.2kb | 2024-07-23 15:58:21 | 2024-07-23 15:58:21 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int cnt[1000005];
void solve(vector<int> &cur, int len, int c1, int c2) {
memset(cnt, 0, sizeof(cnt));
int N = cur.size();
assert(len * c1 + (len + 1) * c2 == N);
vector<int> a, b;
for (int i = 0; i < c1; i++) {
for (int j = i * len; j < (i + 1) * len; j++) {
for (int k = j + 1; k < (i + 1) * len; k++) {
a.emplace_back(cur[j]), b.emplace_back(cur[k]);
}
}
}
for (int i = 0; i < c2; i++) {
for (int j = i * (len + 1); j < (i + 1) * (len + 1); j++) {
for (int k = j + 1; k < (i + 1) * (len + 1); k++) {
a.emplace_back(cur[c1 * len + j]), b.emplace_back(cur[c1 * len + k]);
}
}
}
vector<int> c = ask(a, b), d;
int _id = 0;
for (int i = 0; i < c1; i++) {
for (int j = i * len; j < (i + 1) * len; j++)
for (int k = j + 1; k < (i + 1) * len; k++)
cnt[c[_id++]]++;
int p = -1;
for (int j = i * len; j < (i + 1) * len; j++)
if (cnt[cur[j]] == len - 1) {
p = j;
break;
}
assert(~p), d.emplace_back(cur[p]);
}
for (int i = 0; i < c2; i++) {
for (int j = i * (len + 1); j < (i + 1) * (len + 1); j++)
for (int k = j + 1; k < (i + 1) * (len + 1); k++)
cnt[c[_id++]]++;
int p = -1;
for (int j = i * (len + 1); j < (i + 1) * (len + 1); j++)
if (cnt[cur[c1 * len + j]] == len) {
p = j;
break;
}
assert(~p), d.emplace_back(cur[c1 * len + p]);
}
assert(d.size() == c1 + c2), cur.swap(d);
}
} // namespace
int richest(int N, int T, int S) {
vector<int> cur(N);
iota(cur.begin(), cur.end(), 0);
if (N == 1000) {
solve(cur, 1000, 1, 0);
assert(cur.size() == 1);
return cur[0];
}
assert(N == 1'000'000);
for (int _ = 1; _ <= 4; _++) {
if (N == 1)
return cur[0];
vector<int> a(N / 2), b(N / 2);
for (int i = 0; i < N / 2; i++)
a[i] = cur[i * 2], b[i] = cur[i * 2 + 1];
vector<int> c = ask(a, b);
c.swap(cur), N = cur.size();
}
// cerr << cur.size() << '\n';
solve(cur, 3, 20832, 1);
solve(cur, 6, 3471, 1);
solve(cur, 18, 5, 178);
solve(cur, 183, 1, 0);
return cur[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 596ms
memory: 26548kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2217ms
memory: 90348kb
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: 607ms
memory: 28160kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2248ms
memory: 90352kb
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