QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500602#9156. 百万富翁mirkdang0 277ms83984kbC++141.4kb2024-08-01 16:09:452024-08-01 16:09:47

Judging History

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

  • [2024-08-01 16:09:47]
  • 评测
  • 测评结果:0
  • 用时:277ms
  • 内存:83984kb
  • [2024-08-01 16:09:45]
  • 提交

answer

#include<bits/stdc++.h>
#include"richest.h"
using namespace std;
vector<int> p,q,r,s;
int d[8]={500000,250000,125000,62496,20832,3472,183,1};
void join(vector<int> x)
{
    int l=x.size();
    for(int i=0;i<l;i++)for(int j=i+1;j<l;j++)
        p.push_back(x[i]),q.push_back(x[j]);
    s.push_back(l);
}
void submit(){r=ask(p,q);}
vector<int> result()
{
    vector<int> res;int f=0;
    for(int i:s)
    {
        map<int,int> mp;
        for(int j=0;j<i*(i-1)/2;j++)
            mp[r[f+j]]++;f+=i*(i-1)/2;
        for(auto [x,y]:mp)if(y==i-1)
            res.push_back(x);
    }
    return res;
}
void clear(){p.clear(),q.clear(),s.clear();}
int richest(int N,int T,int S)
{
    if(N==1000)
    {
        vector<int> a,b;a.resize(N);
        iota(a.begin(),a.end(),0);
        join(a),b=result();
        return b[0];
    }
    if(N==1000000)
    {
        vector<int> a;a.resize(N);
        iota(a.begin(),a.end(),0);
        int n=N;
        for(int v=0;v<8;v++)
        {
            clear();
            for(int i=0,lp=0,rp=n/d[v];i<d[v];i++)
            {
                vector<int> b;b.reserve(n/d[v]+5);
                for(int j=lp;j<rp;j++)
                    b.emplace_back(a[j]);
                join(b);
                lp=rp,rp+=n/d[v]+(i+n%d[v]>=d[v]);
            }
            submit(),a=result(),n=d[v];
        }
        return a[0];
    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Runtime Error

input:

1000 1 499500 957319859

output:

Unauthorized output

result:


Pretest #2:

score: 0
Wrong Answer
time: 277ms
memory: 83844kb

input:

1000000 20 2000000 29091473

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer


Final Tests

Test #1:

score: 0
Runtime Error

input:

1000 1 499500 957319857

output:

Unauthorized output

result:


Test #2:

score: 0
Wrong Answer
time: 273ms
memory: 83984kb

input:

1000000 20 2000000 29091471

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer