QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506761 | #9156. 百万富翁 | jijidawang | 100 ✓ | 2004ms | 96484kb | C++20 | 1.9kb | 2024-08-05 21:20:52 | 2024-08-05 21:20:56 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
namespace // my guiding star
{
#define filein(x) freopen(x".in", "r", stdin);
#define fileout(x) freopen(x, "w", stdout);
#define fileerr(x) freopen(x, "w", stderr);
#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);
#define files(x) freopen(x".in", "r", stdin), freopen(x".ans", "w", stdout);
using namespace std;
#define cT const T&
template<typename T>
inline T chkmin(T& x, cT y){if (x > y) x = y; return x;}
template<typename T>
inline T chkmax(T& x, cT y){if (x < y) x = y; return x;}
template <typename T>
inline bool inrange(cT x, cT l, cT r){return (l <= x) && (x <= r);}
template <typename T>
inline bool inrange(cT l, cT r, cT L, cT R){return (L <= l) && (r <= R);}
#undef cT
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef unsigned u32;
template <typename T>
using pr = pair<T, T>;
typedef pr<int> pii;
typedef pr<ll> pll;
typedef pr<db> pdd;
typedef complex<double> cp;
typedef vector<int> vi;
inline void YN(bool x){puts(x ? "Yes" : "No");}
}
const int N = 1e6 + 233;
int p[10] = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
bool ban[N];
int solve(vector<int> A, int d)
{
int n = A.size();
if (n == 1) return A[0];
vector<int> P, Q;
int d1 = n / p[d], d2 = n % p[d];
for (int i=0, c=1; i<n; i++, c++)
{
int r = i + d1 - (c > d2);
for (int j=i; j<r; j++)
for (int k=j+1; k<=r; k++) P.emplace_back(A[j]), Q.emplace_back(A[k]);
i = r;
}
vector<int> R = ask(P, Q);
for (auto x : A) ban[x] = false;
for (int i=0; i<P.size(); i++) ban[P[i] + Q[i] - R[i]] = true;
vector<int> v;
for (auto x : A)
if (!ban[x]) v.emplace_back(x);
return solve(v, d + 1);
}
int richest(int n, int T, int S)
{
if (n <= 1000) p[0] = 1;
vector<int> A(n); iota(A.begin(), A.end(), 0);
return solve(A, 0);
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 596ms
memory: 21340kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2004ms
memory: 96484kb
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: 604ms
memory: 25864kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 1999ms
memory: 96428kb
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