QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502399 | #9156. 百万富翁 | Insert_Username_Here# | 91.00003 | 1976ms | 97808kb | C++20 | 1.7kb | 2024-08-03 05:03:19 | 2024-08-03 05:03:24 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll mod = 1e9 + 7;
// cope counter = 2254
int num[8] = {1, 2, 2, 2, 2, 3, 6, 19};
vector<int> arr, nxt, a, b, c, diff;
int richest(int st, int end) {
int rich = 0, i = st;
for(; i < min((int)a.size(), end); i++) {
if(i == st || a[i] != a[i - 1]) {
if(rich) return a[i - 1];
rich = 1;
}
if(c[i] != a[i]) rich = 0;
}
return c[i - 1];
}
int bf() {
int n = arr.size();
if(n == 1) return arr[0];
a.clear(), b.clear();
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) a.push_back(arr[i]), b.push_back(arr[j]);
}
c = ask(a, b);
return richest(0, a.size());
}
int richest(int n, int t, int s) {
arr.resize(n);
for(int i = 0; i < n; i++) arr[i] = i;
if(t == 1) return bf();
for(int i = 1; i < 8; i++) {
a.clear(), b.clear(), diff.clear();
int sum = 0;
while(sum < n) {
if(num[i] == 3 && sum < 4) diff.push_back(2);
else if(num[i] == 6 && sum < 20) diff.push_back(5);
else if(num[i] == 19 && sum < 72) diff.push_back(18);
else diff.push_back(num[i]);
sum += diff.back();
}
for(int j = 0, cur = 0; j < n; j += diff[cur], cur++) {
for(int i2 = j; i2 < min(n, j + diff[cur]); i2++) {
for(int j2 = i2 + 1; j2 < min(n, j + diff[cur]); j2++) a.push_back(arr[i2]), b.push_back(arr[j2]);
}
}
c = ask(a, b);
nxt.clear();
for(int st = 0, i = 0; st < (int)a.size(); st += diff[i] * (diff[i] - 1) / 2, i++) nxt.push_back(richest(st, st + diff[i] * (diff[i] - 1) / 2));
while(b.back() != arr.back()) nxt.push_back(arr.back()), arr.pop_back();
arr = nxt, n = arr.size();
}
return bf();
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 595ms
memory: 24452kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 76
Acceptable Answer
time: 1949ms
memory: 97720kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947 708834003727782761 0.894118 11625001216319896173
result:
points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
Final Tests
Test #1:
score: 15
Accepted
time: 606ms
memory: 24216kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 76
Acceptable Answer
time: 1976ms
memory: 97808kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947 708834003727782761 0.894118 11625001216319896173
result:
points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947