QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#503199#9156. 百万富翁liaoji91.00003 2339ms111300kbC++141.7kb2024-08-03 16:56:412024-08-03 16:56:44

Judging History

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

  • [2024-08-03 16:56:44]
  • 评测
  • 测评结果:91.00003
  • 用时:2339ms
  • 内存:111300kb
  • [2024-08-03 16:56:41]
  • 提交

answer

#include"richest.h"
#include<bits/stdc++.h>
using namespace std;
const int wk[15]={0,0,19,6,3,2,2,2,2,2};

inline int Ask(vector<int>&v,int N,bool o,vector<int>&a,vector<int>&b) {
    vector<int>vis(N,0),ans;
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++) 
            a.push_back(v[i]),b.push_back(v[j]);
    if(o) return 0;
    ans=ask(a,b);
    int ij=0;
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++)
        {
            if(ans[ij]==v[i]) vis[j]=1;
            else vis[i]=1;
            ++ij;
        }
    for(int i=0;i<N;i++) if(!vis[i]) return v[i];
}

int rev[1000002];
int dfs(int N,int T,vector<int>v) {
    if(N==1) return v[0];
    if(T==1) {
        vector<int>a,b;
        return Ask(v,N,0,a,b);
    }
    vector<int>dv,a,b,ans;
    int d=wk[T];
    int ct=N/d;
    vector<int>s;
    for(int i=1;i<=ct;i++) s.push_back(d);
    if(ct*d<N) s.push_back(N-ct*d);
    while(s.size()>=2&&s[s.size()-2]-s.back()>1) {
        for(int id=s.size()-2;id>=0;id--)
            if(s[id]-s.back()<=1) break;
            else --s[id],++s[s.size()-1];
    }
    for(int i=0,j=0;j<s.size();j++) {
        vector<int>nv(v.begin()+i,v.begin()+i+s[j]);
        Ask(nv,s[j],1,a,b); i+=s[j];
    }
    for(int i=0;i<N;i++) rev[v[i]]=i;
    vector<int>vis(N,0);
    ans=ask(a,b);
    for(int i=0;i<(int)ans.size();i++) {
        if(ans[i]==a[i]) vis[rev[b[i]]]=1;
        else vis[rev[a[i]]]=1;
    }
    for(int i=0;i<N;i++) if(!vis[i]) dv.push_back(v[i]);
    return dfs(dv.size(),T-1,dv);
}

int richest(int N,int T,int S) {
    vector<int>v(N);
    for(int i=0;i<N;i++) v[i]=i;
    if(N==1000) return dfs(N,T,v);
    if(T>=8) return dfs(N,8,v);
}
//g++ grader.cpp richest.cpp -o richest -O2 -std=c++14 -static

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 618ms
memory: 23232kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 76
Acceptable Answer
time: 2339ms
memory: 111300kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947


Final Tests

Test #1:

score: 15
Accepted
time: 590ms
memory: 23276kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 76
Acceptable Answer
time: 2314ms
memory: 111000kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947