QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#493010 | #9156. 百万富翁 | A_programmer | 100 ✓ | 2015ms | 94488kb | C++17 | 1.8kb | 2024-07-26 18:32:04 | 2024-07-26 18:32:05 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int maxn = 1000000;
vi qa, qb, qc;
int deg[maxn + 5];
int op[9] = {1000000, 500000, 250000, 125000, 62498, 20832, 3472, 183, 1};
vi reduce(vi &rem, int y)
{
qa.clear(), qb.clear(); vi res; res.clear();
int x = rem.size(), b = x % y, a = y - b, z = x / y, pos = 0;
for (int i = 0; i < a; i++)
{
for (int j = 0; j < z; j++)
for (int k = j + 1; k < z; k++)
qa.emplace_back(rem[pos + j]), qb.emplace_back(rem[pos + k]);
pos += z;
}
for (int i = 0; i < b; i++)
{
for (int j = 0; j <= z; j++)
for (int k = j + 1; k <= z; k++)
qa.emplace_back(rem[pos + j]), qb.emplace_back(rem[pos + k]);
pos += (z + 1);
}
qc = ask(qa, qb); int nowk = 0; pos = 0;
for (int i = 0; i < maxn; i++) deg[i] = 0;
for (int i = 0; i < a; i++)
{
for (int j = 0; j < z; j++)
for (int k = j + 1; k < z; k++)
deg[qc[nowk]]++, nowk++;
for (int j = 0; j < z; j++) if (deg[rem[pos + j]] == z - 1) res.emplace_back(rem[pos + j]);
pos += z;
}
for (int i = 0; i < b; i++)
{
for (int j = 0; j <= z; j++)
for (int k = j + 1; k <= z; k++)
deg[qc[nowk]]++, nowk++;
for (int j = 0; j <= z; j++) if (deg[rem[pos + j]] == z) res.emplace_back(rem[pos + j]);
pos += (z + 1);
}
return res;
}
int richest(int N, int T, int S)
{
vi rem; rem.clear();
for (int i = 0; i < N; i++) rem.emplace_back(i);
if (T == 1)
{
rem = reduce(rem, 1);
return rem[0];
}
for (int i = 1; i <= 8; i++) rem = reduce(rem, op[i]);
return rem[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 608ms
memory: 28760kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 1997ms
memory: 94476kb
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: 29524kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2015ms
memory: 94488kb
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