QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500636#9156. 百万富翁mirkdang15 754ms83940kbC++141.4kb2024-08-01 16:46:352024-08-01 16:46:36

Judging History

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

  • [2024-08-01 16:46:36]
  • 评测
  • 测评结果:15
  • 用时:754ms
  • 内存:83940kb
  • [2024-08-01 16:46:35]
  • 提交

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 clear(){p.clear(),q.clear(),s.clear();}
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;
}
int richest(int N,int T,int S)
{
    if(N==1000)
    {
        vector<int> a,b;a.resize(N);
        iota(a.begin(),a.end(),0);
        clear(),join(a),submit(),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];
    }
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 740ms
memory: 24364kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 253ms
memory: 83792kb

input:

1000000 20 2000000 29091473

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer


Final Tests

Test #1:

score: 15
Accepted
time: 754ms
memory: 22620kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 243ms
memory: 83940kb

input:

1000000 20 2000000 29091471

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer