QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#505691 | #9156. 百万富翁 | 251Sec | 100 ✓ | 2027ms | 102024kb | C++14 | 1.4kb | 2024-08-05 08:52:50 | 2024-08-05 08:52:51 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int K[] = { 0, 500000, 250000, 125000, 62500, 20833, 3472, 183, 1 };
vector<int> Div(vector<int> a, int k) {
int n = a.size(), p = 0, s = n / k;
vector<int> x, y;
for (int i = 0; i < n % k; i++) {
for (int j = p; j < p + s + 1; j++) {
for (int k = j + 1; k < p + s + 1; k++) {
x.push_back(a[j]), y.push_back(a[k]);
}
}
p += s + 1;
}
for (int i = 0; i < k - n % k; i++) {
for (int j = p; j < p + s; j++) {
for (int k = j + 1; k < p + s; k++) {
x.push_back(a[j]), y.push_back(a[k]);
}
}
p += s;
}
assert(p == n);
p = 0;
vector<int> c = ask(x, y), res;
int cp = 0;
for (int i = 0; i < n % k; i++) {
int u = a[p];
for (int j = p; j < p + s + 1; j++) {
for (int k = j + 1; k < p + s + 1; k++) {
int v = c[cp++];
if (a[j] == u && a[k] == v) u = v;
}
}
p += s + 1;
res.push_back(u);
}
for (int i = 0; i < k - n % k; i++) {
int u = a[p];
for (int j = p; j < p + s; j++) {
for (int k = j + 1; k < p + s; k++) {
int v = c[cp++];
if (a[j] == u && a[k] == v) u = v;
}
}
p += s;
res.push_back(u);
}
return res;
}
int richest(int N, int T, int S) {
vector<int> a;
for (int i = 0; i < N; i++) a.push_back(i);
if (N == 1000) a = Div(a, 1);
else {
for (int i = 1; i <= 8; i++) a = Div(a, K[i]);
}
return a[0];
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 617ms
memory: 21824kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2027ms
memory: 101976kb
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: 23252kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2006ms
memory: 102024kb
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