QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#510034#9156. 百万富翁Rafi22#38.000015 2418ms86344kbC++142.5kb2024-08-08 20:42:592024-08-08 20:43:00

Judging History

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

  • [2024-08-08 20:43:00]
  • 评测
  • 测评结果:38.000015
  • 用时:2418ms
  • 内存:86344kb
  • [2024-08-08 20:42:59]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

int richest(int n,int T,int S)
{
    S=1100000;
    vector<int>V(n);
    FOR(i,0,n-1) V[i]=i;
    int k=2;
    while(sz(V)>=k)
    {
        while(true)
        {
            ll t=0;
            ll x=sz(V);
            debug(k);
            while(x>=k+1)
            {
                t+=(ll)(x/(k+1))*(ll)(k+1)*k/2;
                x=x/(k+1)+x%(k+1);
            }
            t+=(ll)x*(x-1)/2;
            if(S>=t) k++;
            else break;
        }
        vector<int>A,B;
        for(int i=0;i+k-1<sz(V);i+=k)
        {
            FOR(x,i,i+k-1)
            {
                FOR(y,x+1,i+k-1)
                {
                    A.pb(V[x]);
                    B.pb(V[y]);
                }
            }
        }
        vector<int>W=ask(A,B);
        int it=0;
        vector<int>is(sz(V),1);
        for(int i=0;i+k-1<sz(V);i+=k)
        {
            FOR(x,i,i+k-1)
            {
                FOR(y,x+1,i+k-1)
                {
                    if(W[it]!=V[x]) is[x]=0;
                    if(W[it]!=V[y]) is[y]=0;
                    it++;
                }
            }
        }
        S-=sz(A);
        vector<int>nV;
        FOR(i,0,sz(V)-1) if(is[i]) nV.pb(V[i]);
        V=nV;
    }




    if(sz(V)==1) return V[0];
    vector<int>is(sz(V),1);
    vector<int>A,B;
    FOR(i,0,sz(V)-1)
    {
        FOR(j,i+1,sz(V)-1)
        {
            A.pb(V[i]);
            B.pb(V[j]);
        }
    }
    vector<int>W=ask(A,B);
    int it=0;
    FOR(i,0,sz(V)-1)
    {
        FOR(j,i+1,sz(V)-1)
        {
            if(W[it]!=V[i]) is[i]=0;
            if(W[it]!=V[j]) is[j]=0;
            it++;
        }
    }
    FOR(i,0,sz(V)-1) if(is[i]) return V[i];
}







Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Time Limit Exceeded

input:

1000 1 499500 957319859

output:

Unauthorized output

result:


Pretest #2:

score: 38
Acceptable Answer
time: 2387ms
memory: 86220kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 38 / 85, maxt = 10, maxs = 1099999
15723392052912392853
0.447059
12486674425747334617

result:

points 0.447059 Partially correct Case 2, 38 / 85, maxt = 10, maxs = 1099999


Final Tests

Test #1:

score: 0
Time Limit Exceeded

input:

1000 1 499500 957319857

output:

Unauthorized output

result:


Test #2:

score: 38
Acceptable Answer
time: 2418ms
memory: 86344kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 38 / 85, maxt = 10, maxs = 1099999
15723392052912392853
0.447059
12486674425747334617

result:

points 0.447059 Partially correct Case 2, 38 / 85, maxt = 10, maxs = 1099999