QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500574#9156. 百万富翁mirkdang15 769ms51144kbC++141.3kb2024-08-01 15:19:002024-08-01 15:19:01

Judging History

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

  • [2024-08-01 15:19:01]
  • 评测
  • 测评结果:15
  • 用时:769ms
  • 内存:51144kb
  • [2024-08-01 15:19:00]
  • 提交

answer

#include<bits/stdc++.h>
#include"richest.h"
using namespace std;
int x[8]={500000,250000,125000,62496,20832,3472,183,1};
int xhs(vector<int> x)
{
    int l=x.size();
    vector<int> a,b,c;map<int,int> mp;
    a.reserve(l*(l-1)/2),b.reserve(l*(l-1)/2);
    for(int i=0;i<l;i++)for(int j=i+1;j<l;j++)
        a.emplace_back(x[i]),b.emplace_back(x[j]);
    c=ask(a,b);for(int i:c)mp[i]++;
    for(auto [p,q]:mp)if(q==l-1)return p;
}
int richest(int N,int T,int S)
{
    if(N==1000)
    {
        vector<int> a;a.resize(N);
        iota(a.begin(),a.end(),0);
        return xhs(a);
    }
    if(N==1000000)
    {
        vector<int> a;a.resize(N);
        iota(a.begin(),a.end(),0);
        int n=N;
        for(int r=0;r<8;r++)
        {
            vector<int> b(n/x[r]),c(n/x[r]+1),t;
            t.reserve(x[r]);
            for(int i=0;i<x[r]-n%x[r];i++)
            {
                for(int j=0;j<n/x[r];j++)
                    b[j]=a[n/x[r]*i+j];
                t.emplace_back(xhs(b));
            }
            for(int i=0;i<n%x[r];i++)
            {
                for(int j=0;j<n/x[r]+1;j++)
                    c[j]=a[(x[r]-n%x[r])*(n/x[r])+(n/x[r]+1)*i+j];
                t.emplace_back(xhs(c));
            }
            a=t,n=x[r];
        }
        return a[0];
    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 769ms
memory: 20560kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 195ms
memory: 51068kb

input:

1000000 20 2000000 29091473

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries


Final Tests

Test #1:

score: 15
Accepted
time: 767ms
memory: 20528kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 151ms
memory: 51144kb

input:

1000000 20 2000000 29091471

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries