QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502702#9156. 百万富翁liaoji15 618ms23072kbC++141.6kb2024-08-03 12:03:462024-08-03 12:03:46

Judging History

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

  • [2024-08-03 12:03:46]
  • 评测
  • 测评结果:15
  • 用时:618ms
  • 内存:23072kb
  • [2024-08-03 12:03:46]
  • 提交

answer

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

inline int Ask(vector<int>&v,int N) {
    vector<int>vis(N,0);
    vector<int>a,b,ans;
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++)
            a.push_back(i),b.push_back(j);
    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 dfs(int N,int T,vector<int>v) {
    if(N==1) return v[0];
    if(T==1) return Ask(v,N);
    vector<int>dv;
    int d=wk[T];
    for(int i=0;i<N;i+=d) {
        int ed=(i+d<N?i+d:N);
        vector<int>nv(v.begin()+i,v.begin()+ed);
        dv.push_back(Ask(nv,ed-i));
    }
    dfs(dv.size(),T-1,dv);
}

int richest(int N,int T,int S) {
    if(N==1000) {
        vector<int>vis(N,0);
        vector<int>a,b,ans;
        for(int i=0;i<N;i++)
            for(int j=i+1;j<N;j++)
                a.push_back(i),b.push_back(j);
        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]==i) vis[j]=1;
                    else vis[i]=1;
                    ++ij;
                }
        for(int i=0;i<N;i++) if(!vis[i]) return i;
    }
    if(T>=9) {
        vector<int>v(N);
        for(int i=0;i<N;i++) v.push_back(i);
        return dfs(N,T,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: 21908kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Runtime Error

input:

1000000 20 2000000 29091473

output:

Unauthorized output

result:



Final Tests

Test #1:

score: 15
Accepted
time: 605ms
memory: 23072kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Runtime Error

input:

1000000 20 2000000 29091471

output:

Unauthorized output

result: