QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#498665#9156. 百万富翁sunrise2048100 ✓2063ms93732kbC++141.6kb2024-07-30 17:24:142024-07-30 17:24:14

Judging History

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

  • [2024-07-30 17:24:14]
  • 评测
  • 测评结果:100
  • 用时:2063ms
  • 内存:93732kb
  • [2024-07-30 17:24:14]
  • 提交

answer

#include<bits/stdc++.h>
#include "richest.h"
using namespace std;
using ll=long long;
const int f[]={500000,250000,125000,62500,20833,3472,183,1};
const int N=1e6+5;
vector<int> v;
int cn[N];
void ak(int z){
    int n=v.size();
    if(n<=z)return;
    int len1=n%z;
    int len0=z-n%z;
    vector<int> s,t;
    for(int k=0;k<len1;++k){
        int l=k*(n/z+1);
        int r=(k+1)*(n/z+1)-1;
        for(int i=l;i<=r;++i){
            for(int j=i+1;j<=r;++j){
                s.push_back(v[i]);
                t.push_back(v[j]);
            }
        }
    }
    for(int k=0;k<len0;++k){
        int l=len1*(n/z+1)+k*(n/z);
        int r=l+n/z-1;
        for(int i=l;i<=r;++i){
            for(int j=i+1;j<=r;++j){
                s.push_back(v[i]);
                t.push_back(v[j]);
            }
        }
    }
    vector<int> as=ask(s,t);
    for(int i:as)cn[i]++;
    as.clear();
    for(int k=0;k<len1;++k){
        int l=k*(n/z+1);
        int r=(k+1)*(n/z+1)-1;
        for(int i=l;i<=r;++i){
            if(cn[v[i]]==n/z){
                as.push_back(v[i]);
            }
            cn[v[i]]=0;
        }
    }
    for(int k=0;k<len0;++k){
        int l=len1*(n/z+1)+k*(n/z);
        int r=l+n/z-1;
        for(int i=l;i<=r;++i){
            if(cn[v[i]]==n/z-1){
                as.push_back(v[i]);
            }
            cn[v[i]]=0;
        }
    }
    v=as;
}
int richest(int n,int t,int s){
    v.clear();
    for(int i=0;i<n;++i)v.push_back(i);
    if(t==1){
        ak(1);
        return v[0];
    }
    int cn=0;
    while(v.size()!=1){
        ak(f[cn]);++cn;
    }
    return v[0];
}

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 620ms
memory: 27500kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2035ms
memory: 93732kb

input:

1000000 20 2000000 29091473

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944


Final Tests

Test #1:

score: 15
Accepted
time: 616ms
memory: 25504kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2063ms
memory: 93684kb

input:

1000000 20 2000000 29091471

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944