QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#488454 | #9156. 百万富翁 | hos_lyric# | 100 ✓ | 3762ms | 104988kb | C++14 | 1.4kb | 2024-07-24 06:22:52 | 2024-07-24 06:22:52 |
Judging History
answer
#include "richest.h"
using std::vector;
int richest(int N, int T, int S) {
if (T == 1) {
vector<int> as, bs;
for (int u = 0; u < N; ++u) for (int v = u + 1; v < N; ++v) {
as.push_back(u);
bs.push_back(v);
}
const auto res = ask(as, bs);
vector<int> freq(N, 0);
for (const int u : res) ++freq[u];
for (int u = 0; u < N; ++u) if (freq[u] == N - 1) return u;
return -1;
} else {
constexpr int Ks[8] = {
500000,
250000,
125000,
62500,
20832,
3472,
183,
1,
};
vector<int> us(N);
for (int u = 0; u < N; ++u) us[u] = u;
for (int t = 0; t < 8; ++t) {
const int K = Ks[t];
vector<vector<int>> vss(K);
for (int i = 0; i < (int)us.size(); ++i) vss[i % K].push_back(us[i]);
vector<int> as, bs;
for (int k = 0; k < K; ++k) {
const auto &vs = vss[k];
for (int x = 0; x < (int)vs.size(); ++x) for (int y = x + 1; y < (int)vs.size(); ++y) {
as.push_back(vs[x]);
bs.push_back(vs[y]);
}
}
const auto res = ask(as, bs);
vector<int> freq(N, 0);
for (const int u : res) ++freq[u];
us.resize(K);
for (int k = 0; k < K; ++k) {
const auto &vs = vss[k];
us[k] = -1;
for (const int u : vs) if (freq[u] == (int)vs.size() - 1) us[k] = u;
}
}
return us[0];
}
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 618ms
memory: 25368kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3720ms
memory: 104876kb
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: 628ms
memory: 25292kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3762ms
memory: 104988kb
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