QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#509738 | #9156. 百万富翁 | Arapak# | 26.00002 | 2992ms | 99340kb | C++20 | 1.7kb | 2024-08-08 18:04:09 | 2024-08-08 18:04:11 |
Judging History
answer
#include "bits/stdc++.h"
#include "richest.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#ifdef DEBUG
auto& operator<<(auto& os, const pair<auto,auto> &p) {
return os<<"("<<p.first<<", "<<p.second<<")";
}
auto& operator<<(auto& os, const auto &v) {
os<<"{";
for(auto it=begin(v);it!=v.end();++it) {
if(it!=begin(v)) os<<", ";
os<<(*it);
}
return os<<"}";
}
void dbg_out(auto... x) {
((cerr<<' '<<x), ...) << endl;
}
#define dbg(x...) cerr<<"("<<#x<<"):", dbg_out(x);
#else
#define dbg(...)
#endif
int solve(vector<int> ind) {
dbg(ind);
int n = sz(ind);
vector<pii> q;
for(int i=0;i<n;i+=2) {
if(i+2<=n)
q.emplace_back(i, i+1);
}
vi a, b;
for(auto [x, y] : q) {
a.push_back(ind[x]);
b.push_back(ind[y]);
}
dbg(a, b);
vi res = ask(a, b);
dbg(res);
vi new_ind;
for(int i=0;i<n;i+=2) {
if(i+2<=n)
new_ind.push_back(res[i/2]);
else
new_ind.push_back(ind[i]);
}
// for(auto &x : new_ind)
// x = ind[x];
dbg(new_ind);
if(sz(new_ind) == 1) return new_ind[0];
return solve(new_ind);
}
int richest(int N, int T, int S) {
if(T == 1) {
vi a, b;
rep(i,0,N) rep(j,i+1,N) {
a.push_back(i);
b.push_back(j);
}
auto res = ask(a, b);
sort(all(res));
int prev = -1;
int num = 0;
for(auto x : res) {
if(x == prev) {
num++;
if(num == N-1) return x;
}
else {
prev = x;
num = 1;
}
}
assert(false);
}
vi perm(N);
iota(all(perm), 0);
return solve(perm);
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 743ms
memory: 25524kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 11
Acceptable Answer
time: 2898ms
memory: 99312kb
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: 736ms
memory: 25132kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 11
Acceptable Answer
time: 2992ms
memory: 99340kb
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