QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#509727 | #9156. 百万富翁 | Arapak# | 8.99997 | 3766ms | 125412kb | C++20 | 1.8kb | 2024-08-08 17:58:07 | 2024-08-08 17:58:07 |
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+=3) {
if(i+3<=n) {
q.emplace_back(i, i+1);
q.emplace_back(i, i+2);
q.emplace_back(i+1, i+2);
}
else 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+=3) {
if(i+3<=n) {
auto check = [&](const int index) {
int num = 0;
num += res[i] == ind[index];
num += res[i+1] == ind[index];
num += res[i+2] == ind[index];
return num == 2;
};
if(check(i)) new_ind.push_back(ind[i]);
else if(check(i+1)) new_ind.push_back(ind[i+1]);
else new_ind.push_back(ind[i+2]);
}
else if(i+2<=n)
new_ind.push_back(res[i]);
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) {
vi perm(N);
iota(all(perm), 0);
return solve(perm);
}
详细
Pretests
Pretest #1:
score: 0
Wrong Answer
time: 1ms
memory: 8136kb
input:
1000 1 499500 957319859
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries
Pretest #2:
score: 8.99997
Acceptable Answer
time: 3760ms
memory: 124240kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997 7616820272462450011 0.105882 16926627793318235567
result:
points 0.105882 Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997
Final Tests
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8016kb
input:
1000 1 499500 957319857
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries
Test #2:
score: 8.99997
Acceptable Answer
time: 3766ms
memory: 125412kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997 7616820272462450011 0.105882 16926627793318235567
result:
points 0.105882 Partially correct Case 2, 9 / 85, maxt = 13, maxs = 1499997