QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740508 | #9156. 百万富翁 | remmymilkyway | 15 | 633ms | 23344kb | C++14 | 2.2kb | 2024-11-13 10:14:18 | 2024-11-13 10:14:18 |
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;
// }
int getmx(vector<int> vec) {
vector<int> q1, q2;
for (int i = 0; i < (int)vec.size(); i++) {
for (int j = i + 1; j < (int)vec.size(); j++) {
q1.push_back(vec[i]);
q2.push_back(vec[j]);
}
}
vector<int> res = ask(q1, q2);
vector<int> cnt((int)vec.size(), 0);
int cur = 0;
for (int i = 0; i < (int)vec.size(); i++) {
for (int j = i + 1; j < (int)vec.size(); j++) {
if (res[cur] == vec[i]) {
cnt[i]++;
} else {
cnt[j]++;
}
cur++;
}
}
for (int i = 0; i < (int)vec.size(); i++) {
if (cnt[i] == (int)vec.size() - 1) {
return vec[i];
}
}
throw string("The getmx function is errornous, damn.");
}
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);
}
return getmx(vec);
}
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;
nxt.clear();
for (int j = 0; j < table[i]; j++) {
vector<int> q;
int sz = (int)cur.size() / j + (j < (int)cur.size() % table[i]);
for (int ii = 0; ii < sz; ii++) {
q.push_back(st + ii);
}
nxt.push_back(getmx(q));
st += sz;
}
cur = nxt;
}
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: 626ms
memory: 21944kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 633ms
memory: 23344kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091471
output:
Unauthorized output