QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740600 | #9156. 百万富翁 | remmymilkyway | 100 ✓ | 3522ms | 123520kb | C++14 | 2.6kb | 2024-11-13 10:40:32 | 2024-11-13 10:40:33 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// vector<int> ask(vector<int> i, vector<int> j) {
// assert((int)i.size() == (int)j.size());
// vector<int> ret;
// for (int idx = 0; idx < (int)i.size(); idx++) {
// cout << "? " << i[idx] << ' ' << j[idx] << endl;
// int res;
// cin >> res;
// ret.push_back(res);
// }
// return ret;
// }
vector<int> getmx(int sz, vector<vector<int>> vec) {
vector<int> q1, q2;
for (auto svec : vec) {
for (int i = 0; i < (int)svec.size(); i++) {
for (int j = i + 1; j < (int)svec.size(); j++) {
q1.push_back(svec[i]);
q2.push_back(svec[j]);
}
}
}
vector<int> res = ask(q1, q2);
vector<int> cnt(sz, 0);
int cur = 0, cursz = 0;
for (auto svec : vec) {
for (int i = 0; i < (int)svec.size(); i++) {
for (int j = i + 1; j < (int)svec.size(); j++) {
if (res[cur] == svec[i]) {
cnt[cursz + i]++;
} else {
cnt[cursz + j]++;
}
cur++;
}
}
cursz += (int)svec.size();
}
vector<int> ret;
cursz = 0;
for (auto svec : vec) {
for (int i = 0; i < (int)svec.size(); i++) {
if (cnt[cursz + i] == (int)svec.size() - 1) {
ret.push_back(svec[i]);
}
}
cursz += (int)svec.size();
}
return ret;
}
int richest(int N, int T, int S) {
if (T == 1) {
vector<int> vec;
for (int i = 0; i < N; i++) {
vec.push_back(i);
}
vector<vector<int>> tmp;
tmp.push_back(vec);
return getmx(N, tmp)[0];
}
vector<int> cur, nxt;
for (int i = 0; i < N; i++) {
cur.push_back(i);
}
const int t = 8;
const int table[t] = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
for (int i = 0; i < t; i++) {
int st = 0;
vector<vector<int>> qs;
for (int j = 0; j < table[i]; j++) {
vector<int> q;
int sz = (int)cur.size() / table[i] + (j < (int)cur.size() % table[i]);
for (int ii = 0; ii < sz; ii++) {
q.push_back(cur[st + ii]);
}
qs.push_back(q);
st += sz;
}
cur = getmx((int)cur.size(), qs);
}
return cur[0];
}
// int main() {
// int N, T, S;
// cin >> N >> T >> S;
// cout << richest(N, T, S) << '\n';
// return 0;
// }
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 631ms
memory: 23192kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3515ms
memory: 121444kb
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: 633ms
memory: 23132kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3522ms
memory: 123520kb
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