QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#533798 | #9156. 百万富翁 | liyujia | 100 ✓ | 2143ms | 120436kb | C++14 | 2.0kb | 2024-08-26 14:39:20 | 2024-08-26 14:39:20 |
Judging History
answer
#include <bits/stdc++.h>
int w[1000005];
std::vector<int> aask(std::vector<int> a, std::vector<int> b){
std::vector <int> c; c.resize(a.size());
for(int i = 0; i < a.size(); i++)
if(w[a[i]] > w[b[i]]) c[i] = a[i];
else c[i] = b[i];
return c;
}
std::vector<int> ask(std::vector<int> a, std::vector<int> b);
using namespace std;
const int c[] = {1000000, 500000, 250000, 125000, 62498, 20832, 3472, 183, 1};
int v[1000005];
vector <int> t[500005];
int richest(int n, int T, int S){
vector <int> a, b;
if(n <= 1000){
memset(v, 0, sizeof v);
for(int i = 1; i <= n; i++) for(int j = i + 1; j <= n; j++) a.push_back(i - 1), b.push_back(j - 1);
auto c = ask(a, b);
for(int i: c) v[i + 1]++;
for(int i = 1; i <= n; i++) if(v[i] == n - 1) return i - 1;
assert(0);
} vector <int> f;
for(int i = 1; i <= n; i++) f.push_back(i);
for(int i = 1; i <= 8; i++){
for(int i: f) v[i] = 0;
a.clear(), b.clear();
int k = c[i - 1] / c[i], now = 0, cnt = 1;
for(int j = 1; j <= c[i - 1] % c[i]; j++){
t[++cnt].clear();
for(int l = 0; l <= k; l++, now++) t[cnt].push_back(f[now]);
for(int l = 0; l < t[cnt].size(); l++) for(int o = l + 1; o < t[cnt].size(); o++)
a.push_back(t[cnt][l] - 1), b.push_back(t[cnt][o] - 1);
}
for(int j = 1; j <= c[i] - c[i - 1] % c[i]; j++){
t[++cnt].clear();
for(int l = 0; l < k; l++, now++) t[cnt].push_back(f[now]);
for(int l = 0; l < t[cnt].size(); l++) for(int o = l + 1; o < t[cnt].size(); o++)
a.push_back(t[cnt][l] - 1), b.push_back(t[cnt][o] - 1);
}
auto c = ask(a, b); vector <int> h = {};
for(int j: c) v[j + 1]++;
for(int j = 1; j <= cnt; j++)
for(int l: t[j]) if(v[l] == t[j].size() - 1) h.push_back(l);
f = h;
} return f[0] - 1;
}
int maain(){
int n, ans; cin >> n; mt19937 rnd(time(0));
iota(w, w + n, 1), shuffle(w, w + n, rnd);
for(int i = 0; i < n; i++) if(w[i] == n) ans = i;
cout << richest(n, 114514, 1919810) << ' ' << ans;
return 0;
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 616ms
memory: 41868kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2143ms
memory: 119024kb
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: 625ms
memory: 43692kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2142ms
memory: 120436kb
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