QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526538#9156. 百万富翁lefy100 ✓2080ms97008kbC++141.3kb2024-08-21 17:12:592024-08-21 17:12:59

Judging History

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

  • [2024-08-21 17:12:59]
  • 评测
  • 测评结果:100
  • 用时:2080ms
  • 内存:97008kb
  • [2024-08-21 17:12:59]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
const int N=1e6+10;
int du[N];
int L[N],R[N],Nm[10]={0,500000,250000,125000,62500,20832,3472,183,1};
int richest(int n, int T, int S){
    if(n==1000){
        for(int i=0;i<n;i++)du[i]=0;
        vector<int>a,b;
        for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)a.push_back(i-1),b.push_back(j-1);
        a=ask(a,b);
        for(int x:a)du[x]++;
        for(int i=0;i<n;i++)if(du[i]==n-1)return i;
        return -1;
    }
    vector<int>a,b,t,t1;
    for(int i=0;i<n;i++)t.push_back(i);int nn=n;
    for(int nm=1;nm<=8;nm++){
        int num=Nm[nm];
        t1=t;
        for(int i=0;i<nn;i++)du[i]=0;
        n=t.size();a.clear(),b.clear();
        int s=ceil(1.0*n/num);R[0]=-1;
        for(int i=1;i<=num;i++){
            L[i]=R[i-1]+1;
            if(n%num==0)R[i]=L[i]+s-1;
            else if(n%num>=i)R[i]=L[i]+s-1;else R[i]=L[i]+s-2;
            for(int j=L[i];j<=R[i];j++)for(int k=j+1;k<=R[i];k++)a.push_back(t[j]),b.push_back(t[k]);
            
        }
        t=ask(a,b);
        for(int x:t)du[x]++;
        a.clear(),b.clear();t.clear();
        for(int i=1;i<=num;i++){
            int len=R[i]-L[i];
            for(int j=L[i];j<=R[i];j++)if(du[t1[j]]==len)t.push_back(t1[j]);
        }
    }
    return t[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 625ms
memory: 27372kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2077ms
memory: 95716kb

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: 628ms
memory: 27204kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2080ms
memory: 97008kb

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