QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#509978#9156. 百万富翁Rafi22#39.000005 2018ms97108kbC++141.9kb2024-08-08 20:18:102024-08-08 20:18:11

Judging History

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

  • [2024-08-08 20:18:11]
  • 评测
  • 测评结果:39.000005
  • 用时:2018ms
  • 内存:97108kb
  • [2024-08-08 20:18:10]
  • 提交

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=1199944;
    vector<int>V(n);
    FOR(i,0,n-1) V[i]=i;
    while(sz(V)>1)
    {
        ll t=(ll)sz(V)*(sz(V)-1)/2;
        if(S>=t)
        {
            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];
        }
        vector<int>A,B;
        for(int i=0;i+1<sz(V);i+=2)
        {
            A.pb(V[i]);
            B.pb(V[i+1]);
        }
        vector<int>nV=ask(A,B);
        S-=sz(A);
        if(sz(V)%2==1) nV.pb(V.back());
        V=nV;
    }
    return V[0];
}




















Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 636ms
memory: 21436kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 24
Acceptable Answer
time: 2018ms
memory: 85864kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 24 / 85, maxt = 12, maxs = 1118827
2893638666736527915
0.282353
2192392354278883037

result:

points 0.282353 Partially correct Case 2, 24 / 85, maxt = 12, maxs = 1118827


Final Tests

Test #1:

score: 15
Accepted
time: 636ms
memory: 23832kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 24
Acceptable Answer
time: 2008ms
memory: 97108kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 24 / 85, maxt = 12, maxs = 1118827
2893638666736527915
0.282353
2192392354278883037

result:

points 0.282353 Partially correct Case 2, 24 / 85, maxt = 12, maxs = 1118827