QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#496598 | #9156. 百万富翁 | ucup-team1004 | 100 ✓ | 2890ms | 125036kb | C++14 | 1.5kb | 2024-07-28 13:41:19 | 2024-07-28 13:41:20 |
Judging History
answer
#include"richest.h"
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=1e6+10;
vector<int>solve(vector<vector<int>>a){
vector<int>p,q;
for(auto &b:a){
for(int i=0;i<b.size();i++){
for(int j=0;j<i;j++){
p.push_back(b[i]),q.push_back(b[j]);
}
}
}
auto res=ask(p,q);
int cur=0;
vector<int>ans;
for(auto &b:a){
vector<int>cnt(b.size(),0);
static int pos[N];
for(int i=0;i<b.size();i++)pos[b[i]]=i;
for(int i=0;i<b.size();i++){
for(int j=0;j<i;j++){
cnt[pos[res[cur++]]]++;
}
}
ans.push_back(b[max_element(all(cnt))-cnt.begin()]);
}
return ans;
}
int richest(int n,int T,int S){
vector<int>a(n);
iota(all(a),0);
if(n==1000){
auto res=solve({a});
return res[0];
}
for(int T=4;T--;){
vector<vector<int>>b;
for(int i=0;i<a.size();i+=2){
b.push_back({a[i],a[i+1]});
}
a=solve(b);
debug(T,a.size());
}
for(int x:{3,6,19}){
vector<vector<int>>b;
for(int i=0;i<a.size();){
int k=x;
if(x==3)k+=(a.size()-i)%x>0;
if(x==6)k+=(a.size()-i)%x>0;
if(x==19)k-=(a.size()-i)%x>0;
vector<int>c;
for(int j=0;j<k;j++)c.push_back(a[i+j]);
b.push_back(c);
i+=k;
}
a=solve(b);
debug(x,a.size());
}
auto res=solve({a});
return res[0];
}
#ifdef DEBUG
#include"debug.hpp"
#endif
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 614ms
memory: 25032kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2876ms
memory: 120508kb
input:
1000000 20 2000000 29091473
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
Final Tests
Test #1:
score: 15
Accepted
time: 615ms
memory: 26364kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2890ms
memory: 125036kb
input:
1000000 20 2000000 29091471
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944