QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#488487 | #9156. 百万富翁 | Sktn0089 | 100 ✓ | 2028ms | 101648kb | C++14 | 2.1kb | 2024-07-24 08:23:21 | 2024-07-24 08:23:57 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
#define ll int
#define ull unsigned ll
#define pb push_back
using namespace std;
const ll maxn = 1e6 + 10, mod = 998244353;
ll n = 1e6, a[9] = {1000000, 500000, 250000, 125000, 62496, 20832, 3472, 183, 1};
vector <ll> v1, v2, reply;
ll fail[maxn], id[maxn], pid[maxn];
ll richest(ll N, ll T, ll S) {
if(N <= 1000) {
v1.clear(), v2.clear();
for(ll i = 1; i <= N; i++) fail[i] = 0;
for(ll i = 1; i <= N; i++)
for(ll j = i + 1; j <= N; j++)
v1.pb(i - 1), v2.pb(j - 1);
reply = ask(v1, v2);
ll p = 0;
for(ll i = 1; i <= N; i++)
for(ll j = i + 1; j <= N; j++)
fail[(reply[p++] + 1) ^ i ^ j] = 1;
for(ll i = 1; i <= N; i++)
if(fail[i] == 0) return i - 1;
}
for(ll i = 1; i <= n; i++) id[i] = i;
for(ll i = 1; i <= 8; i++) {
for(ll j = 1; j <= n; j++) fail[j] = 0;
ll t = a[i - 1] / a[i], u = a[i - 1] % a[i];
ll p1 = a[i] - u, p2 = u;
v1.clear(), v2.clear();
for(ll j = 1; j <= p1; j++) {
ll l = (j - 1) * t + 1, r = j * t;
for(ll x = l; x <= r; x++)
for(ll y = x + 1; y <= r; y++)
v1.pb(id[x] - 1), v2.pb(id[y] - 1);
// printf("[%d, %d]\n", l, r);
}
for(ll j = 1; j <= p2; j++) {
ll l = (j - 1) * (t + 1) + 1, r = j * (t + 1);
l += p1 * t, r += p1 * t;
for(ll x = l; x <= r; x++)
for(ll y = x + 1; y <= r; y++)
v1.pb(id[x] - 1), v2.pb(id[y] - 1);
// printf("[%d, %d]\n", l, r);
} reply = ask(v1, v2); ll p = 0, e = 0;
for(ll j = 1; j <= p1; j++) {
ll l = (j - 1) * t + 1, r = j * t;
for(ll x = l; x <= r; x++)
for(ll y = x + 1; y <= r; y++)
fail[id[x] ^ id[y] ^ (reply[p++] + 1)] = 1;
for(ll x = l; x <= r; x++)
if(fail[id[x]] == 0) pid[++e] = id[x];
}
for(ll j = 1; j <= p2; j++) {
ll l = (j - 1) * (t + 1) + 1, r = j * (t + 1);
l += p1 * t, r += p1 * t;
for(ll x = l; x <= r; x++)
for(ll y = x + 1; y <= r; y++)
fail[id[x] ^ id[y] ^ (reply[p++] + 1)] = 1;
for(ll x = l; x <= r; x++)
if(fail[id[x]] == 0) pid[++e] = id[x];
}
for(ll j = 1; j <= a[i]; j++) id[j] = pid[j];
} return id[1] - 1;
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 601ms
memory: 26236kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2028ms
memory: 101648kb
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: 616ms
memory: 24732kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2002ms
memory: 101524kb
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