QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490137 | #9156. 百万富翁 | strcmp# | 26.00002 | 2322ms | 98532kb | C++14 | 1.6kb | 2024-07-25 11:43:17 | 2024-07-25 11:43:17 |
Judging History
answer
#include <bits/stdc++.h>
//#include <windows.h>
using namespace std;
#include "richest.h"
#define rep(i, a, b) for(int i = a; i <= b; i++)
using vec = vector<int>;
using ll = long long int;
constexpr int maxn = 2e6 + 10;
#define ps push_back
vec p, np, a, b; int n, t, s, cnt[maxn];
int qry(int l, int r) {
if (l == r) return p[l];
a.clear(); b.clear();
for (int i = l; i < r; i++) {
for (int j = i + 1; j <= r; j++) a.ps(p[i]), b.ps(p[j]);
}
vec c = ask(a, b); int ans = 0;
for (int i = 0; i < c.size(); i++) {
++cnt[c[i]];
if (cnt[c[i]] == r - l) ans = c[i];
}
for (int i = 0; i < c.size(); i++) --cnt[c[i]];
a.clear(); b.clear();
return ans;
}
void qwq(int l, int r) {
for (int i = l; i < r; i++) {
for (int j = i + 1; j <= r; j++) a.ps(p[i]), b.ps(p[j]);
}
}
void divide(int k) {
for (int i = 0; i < n; i += k) {
int j = min(i + k - 1, n - 1);
qwq(i, j);
}
vec c = ask(a, b); int L = 0;
for (int i = 0; i < n; i += k) {
int j = min(i + k - 1, n - 1);
int len = j - i + 1;
if (len == 1) { np.ps(p[i]); continue; }
int wx = len * (len - 1) / 2;
int R = L + wx - 1, ans = p[i];
for (int k = L; k <= R; k++) {
++cnt[c[k]];
if (cnt[c[k]] == len - 1) ans = c[k];
}
for (int k = L; k <= R; k++) --cnt[c[k]];
np.ps(ans); L = R + 1;
}
p = np; n = p.size(); np.clear(); a.clear(); b.clear();
}
int richest(int N, int T, int S) {
n = N, t = T, s = S; p.clear(); np.clear();
for (int i = 0; i < n; i++) p.ps(i);
for (int i = 1; i < t; i++) if (n >= 2) divide(2);
//for (int i = 0; i < n; i++) cerr << p[i] << " "; cerr << "\n";
//Sleep(5000);
return qry(0, n - 1);
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 626ms
memory: 22680kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 11
Acceptable Answer
time: 2322ms
memory: 97304kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999 1811468636458994965 0.129412 3823502568050958645
result:
points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999
Final Tests
Test #1:
score: 15
Accepted
time: 625ms
memory: 22568kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 11
Acceptable Answer
time: 2317ms
memory: 98532kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999 1811468636458994965 0.129412 3823502568050958645
result:
points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999