QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#604137#9156. 百万富翁shinzanmono15 636ms24064kbC++232.0kb2024-10-01 23:40:282024-10-01 23:40:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-01 23:40:29]
  • 评测
  • 测评结果:15
  • 用时:636ms
  • 内存:24064kb
  • [2024-10-01 23:40:28]
  • 提交

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

result: