QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#560935 | #9156. 百万富翁 | zhazha21 | 100 ✓ | 2048ms | 90364kb | C++14 | 2.5kb | 2024-09-12 19:01:41 | 2024-09-12 19:01:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int g[8] = {500000, 250000, 125000, 62500, 20832, 3472, 183, 1};
int cnt[1000005];
vector<int> ask(vector<int> a, vector<int> b);
int richest(int N, int T, int S)
{
int ttt = 8;
if(N <= 1000){
g[0] = 1;
ttt = 1;
}
vector<int> res;
res.reserve(N);
for (int i = 0; i < N; i++)
res.push_back(i);
for (int i = 0; i < ttt; i++)
{
vector<int> a, b;
int p = res.size() / g[i], G = res.size() % g[i]; // p: ppl in group, G: group+ num
for (int k = 0; k < G; k++) // group+
{
int l = k * (p + 1), r = (k + 1) * (p + 1); // group [l,r) with p+1 ppl
for (int I = l; I < r; I++)
{
for (int J = I + 1; J < r; J++)
{
a.push_back(res[I]), b.push_back(res[J]); // do query
}
}
}
for (int k = G; k < g[i]; k++) // group
{
int l = G + k * p, r = G + (k + 1) * p; // group [l,r) with p ppl
for (int I = l; I < r; I++)
{
for (int J = I + 1; J < r; J++)
{
a.push_back(res[I]), b.push_back(res[J]);
}
}
}
vector<int> ans = ask(a, b);
vector<int> res2; // new res
int pos = 0;
for (int k = 0; k < G; k++)
{
int l = k * (p + 1), r = (k + 1) * (p + 1);
for (int I = l; I < r; I++)
{
for (int J = I + 1; J < r; J++)
{
cnt[ans[pos++]]++; // count the larger
}
}
for (int I = l; I < r; I++)
{
if (cnt[res[I]] == p)
res2.push_back(res[I]);
}
for (int I = l; I < r; I++)
cnt[res[I]] = 0;
}
for (int k = G; k < g[i]; k++)
{
int l = G + k * p, r = G + (k + 1) * p;
for (int I = l; I < r; I++)
{
for (int J = I + 1; J < r; J++)
{
cnt[ans[pos++]]++;
}
}
for (int I = l; I < r; I++)
{
if (cnt[res[I]] == p - 1)
res2.push_back(res[I]);
}
for (int I = l; I < r; I++)
cnt[res[I]] = 0;
}
res = res2;
}
return res[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 621ms
memory: 23956kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2048ms
memory: 90364kb
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: 613ms
memory: 25244kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2043ms
memory: 82752kb
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