QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501692 | #9156. 百万富翁 | myd | 0 | 0ms | 0kb | C++14 | 2.0kb | 2024-08-02 21:55:55 | 2024-08-02 21:55:55 |
answer
#include "richest.h"
#include <vector>
#include <cstdio>
namespace Main {
using namespace std;
typedef long long LL;
typedef unsigned int UI;
typedef unsigned long long UL;
typedef __int128_t LI;
LL read() {
LL res, f = 1, ch;
for (ch = getchar(); (ch < '0' || ch > '9') && ch != EOF; ch = getchar())
if (ch == '-')
f = -1;
for (res = 0; ch >= '0' && ch <= '9'; ch = getchar())
res = (res << 3) + (res << 1) + (ch & 15);
return res * f;
}
constexpr bool T = 0;
constexpr int N = 1000005;
constexpr int a[8] = {500000, 250000, 125000, 62496, 20832, 3472, 183, 1};
int c[N];
vector<int> va, vb;
void query(vector<int> &vc, int p = 0, int n = -1, int op = 0) {
if (n < 0)
n = vc.size();
if (!op) {
va.clear();
vb.clear();
}
for (int i = p; i < p + n; ++i)
for (int j = i + 1; j < p + n; ++j) {
va.emplace_back(i);
vb.emplace_back(j);
}
return;
}
int cal(vector<int> &vc, int p = 0, int n = -1) {
if (n < 0)
n = vc.size();
for (int i = p; i < p + n; ++i)
++c[vc[i]];
int mx = 0;
for (int i = p; i < p + n; ++i)
if (c[vc[i]] > c[mx])
mx = vc[i];
for (int i = p; i < p + n; ++i)
c[vc[i]] = 0;
return mx;
}
vector<int> sol(vector<int> &vc, int m) {
int n = vc.size(), d = n / m, r = n % m, p = 0;
va.clear();
vb.clear();
for (int i = 0; i < r; ++i, p += d + 1)
query(vc, p, d + 1, 1);
for (int i = r; i < m; ++i, p += d)
query(vc, p, d, 1);
int t = d * (d - 1) / 2;
vector<int> res = ask(va, vb), ans;
for (int i = 0; i < r; ++i, p += t + d)
ans.emplace_back(cal(res, p, t + d));
for (int i = r; i < m; ++i, p += t)
ans.emplace_back(cal(res, p, t));
return ans;
}
int solve(int n, int t, int s) {
vector<int> vc;
for (int i = 0; i < n; ++i)
vc.emplace_back(i);
if (t == 1)
return sol(vc, 1)[0];
for (int k = 0; vc.size() > 1 && k < 8; ++k)
vc = sol(vc, min((int)vc.size(), a[k]));
return vc[0];
}
} // namespace Main
int richest(int N, int T, int S) {
return Main::solve(N, T, S);
}
详细
Pretests
Pretest #1:
score: 0
Runtime Error
input:
1000 1 499500 957319859
output:
Unauthorized output
result:
Pretest #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 0
Runtime Error
input:
1000 1 499500 957319857
output:
Unauthorized output
result:
Test #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091471
output:
Unauthorized output