QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#604137 | #9156. 百万富翁 | shinzanmono | 15 | 636ms | 24064kb | C++23 | 2.0kb | 2024-10-01 23:40:28 | 2024-10-01 23:40:29 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<vector>
std::vector<int> ask(std::vector<int>a,std::vector<int>b);
std::unordered_map<int,int>cnt;
int max(std::vector<int>::iterator begin,std::vector<int>::iterator end){
for(auto it=begin;it!=end;++it)cnt[*it]++;
int max=-1;
for(auto p:cnt)if(p.second>cnt[max])max=p.first;
cnt.clear();
return max;
}
std::vector<int>cur,C({2,2,2,2,3,6,19,183});
int richest(int N,int T,int S){
if(N==1000){
std::vector<int>a,b;
for(int i=0;i<N;i++)
for(int j=i+1;j<N;j++)
a.push_back(i),b.push_back(j);
std::vector<int>v(ask(a,b));
return max(v.begin(),v.end());
}
for(int i=0;i<N;i++)cur.push_back(i);
for(int p:C){
int a=N%p,b=N/p-a;
std::vector<int>va,vb,ans,size(1);
if(a<=p/2){
for(int i=0;i<N;){
for(int x=i;x<=i+p-(a==0);x++)
for(int y=x+1;y<=i+p-(a==0);y++)
va.push_back(cur[x]),vb.push_back(cur[y]);
size.push_back(va.size());
if(a!=0)a--,i+=p+1;
else b--,i+=p;
}
std::vector<int>v=ask(va,vb);
for(int i=1;i<=N/p;i++)
ans.push_back(max(v.begin()+size[i-1],v.begin()+size[i]));
cur.swap(ans),N=cur.size();
}else{
a=p-a,b=N/p-b+1;
for(int i=0;i<N;){
for(int x=i;x<=i+p-1-(a==0);x++)
for(int y=x+1;y<=i+p-1-(a==0);y++)
va.push_back(cur[x]),vb.push_back(cur[y]);
size.push_back(va.size());
if(a!=0)a--,i+=p+1;
else b--,i+=p;
}
std::vector<int>v=ask(va,vb);
for(int i=1;i<=N/p+1;i++)
ans.push_back(max(v.begin()+size[i-1],v.begin()+size[i]));
cur.swap(ans),N=cur.size();
}
}
return cur[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 636ms
memory: 21504kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 636ms
memory: 24064kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091471
output:
Unauthorized output