QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492363 | #9156. 百万富翁 | zfs732# | 77.99996 | 2020ms | 85532kb | C++23 | 2.2kb | 2024-07-26 11:38:40 | 2024-07-26 11:38:41 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
int Force(std::vector<int> id) {
int N = (int) id.size();
std::vector g(N, std::vector<bool>(N));
std::vector<int> A, B;
for (int i = 0; i < N; i++)
for (int j = i + 1; j < N; j++) {
A.emplace_back(id[i]);
B.emplace_back(id[j]);
}
auto res = ask(A, B);
for (int i = 0, tot = 0; i < N; i++)
for (int j = i + 1; j < N; j++) {
int c = res[tot++] == id[i];
g[i][j] = c, g[j][i] = !c;
}
for (int i = 0; i < N; i++) {
int cnt = 0;
for (int j = 0; j < N; j++)
cnt += g[i][j];
if (cnt == N - 1)
return id[i];
}
return -1;
}
int richest(int N, int T, int S) {
std::vector<int> cur;
for (int i = 0; i < N; i++)
cur.emplace_back(i);
if (T == 1) return Force(cur);
for (int step = 0; step < 6; step++) {
int m = (int) cur.size(), ext = -1;
std::vector<int> A, B;
for (int i = 0; i + 1 < m; i += 2) {
A.emplace_back(cur[i]);
B.emplace_back(cur[i ^ 1]);
}
if (m & 1) ext = cur.back();
cur = ask(A, B);
if (~ext) cur.emplace_back(ext);
}
for (int step = 0; step < 2; step++) {
const int SI = 10;
std::vector<int> A, B;
int m = (int) cur.size();
for (int l = 0; l < m; l++) {
int r = std::min(l + SI, m) - 1;
for (int i = l; i <= r; i++)
for (int j = i + 1; j <= r; j++) {
A.emplace_back(cur[i]);
B.emplace_back(cur[j]);
}
l = r;
}
std::vector<int> tmp;
auto res = ask(A, B);
int tot = 0;
for (int l = 0; l < m; l++) {
int r = std::min(l + SI, m) - 1, len = r - l + 1;
std::map<int, std::map<int, int>> g;
for (int i = l; i <= r; i++)
for (int j = i + 1; j <= r; j++) {
int c = res[tot++] == cur[i];
g[i][j] = c, g[j][i] = !c;
}
for (int i = l; i <= r; i++) {
int cnt = 0;
for (int j = l; j <= r; j++)
cnt += g[i][j];
if (cnt == len - 1)
tmp.emplace_back(cur[i]);
}
l = r;
}
cur = tmp;
}
return Force(cur);
}
/*
* 1000000 20 2000000 1
*/
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 624ms
memory: 25224kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 63
Acceptable Answer
time: 2005ms
memory: 85472kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1073944 17082859050064462749 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1073944
Final Tests
Test #1:
score: 15
Accepted
time: 627ms
memory: 23312kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 63
Acceptable Answer
time: 2020ms
memory: 85532kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1073944 17082859050064462749 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1073944