QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686178 | #9156. 百万富翁 | alontanay | 100 ✓ | 3114ms | 140616kb | C++17 | 2.0kb | 2024-10-29 06:01:50 | 2024-10-29 06:01:52 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
const vector<int> subtasks[2] = {
{1000, 1}, {1000000, 500000, 250000, 125000, 62496, 20832, 3472, 183, 1}};
const int MAX_N = 1'000'005;
int _del_date[MAX_N];
int _cur_date = 1;
vector<int> query(vector<vector<int>> groups) {
_cur_date++;
vector<int> side_a, side_b;
for (vector<int> &group : groups) {
for (int a : group) {
for (int b : group) {
if (a == b) {
break;
}
side_a.push_back(a);
side_b.push_back(b);
}
}
}
vector<int> response = ask(side_a, side_b);
for (int i = 0; i < side_a.size(); i++) {
if (response[i] == side_a[i]) {
_del_date[side_b[i]] = _cur_date;
} else {
_del_date[side_a[i]] = _cur_date;
}
}
vector<int> res;
for (vector<int> &group : groups) {
for (int a : group) {
if (_del_date[a] != _cur_date) {
res.push_back(a);
}
}
}
return res;
}
#define ask
int richest(int N, int T, int S) {
vector<int> sizes = subtasks[T != 1];
_cur_date++;
vector<int> candidates(N);
iota(candidates.begin(), candidates.end(), 0);
for (int d = 1; d < sizes.size(); d++) {
int before = sizes[d - 1], after = sizes[d];
int div = before / after;
int rem = before % after;
assert(candidates.size() <= before);
vector<vector<int>> groups;
int idx = 0;
for (int gi = 0; gi < after; gi++) {
vector<int> group;
for (int _i = gi >= rem; _i <= div; _i++) {
if (idx == candidates.size()) break;
group.push_back(candidates[idx++]);
}
groups.push_back(group);
}
candidates = query(groups);
assert(candidates.size() <= after);
}
return candidates[0];
}
#undef ask
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 606ms
memory: 27116kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3074ms
memory: 127188kb
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: 612ms
memory: 24908kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3114ms
memory: 140616kb
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