QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#510060 | #9156. 百万富翁 | Rafi22# | 77.99996 | 2288ms | 86012kb | C++14 | 2.7kb | 2024-08-08 20:54:10 | 2024-08-08 20:54:10 |
Judging History
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 calc(int x,int k)
{
int ile=0;
while(x>=k)
{
ile++;
x=x/k+x%k;
}
if(x>1) ile++;
return ile;
}
int richest(int n,int T,int S)
{
S=1099944;
vector<int>V(n);
FOR(i,0,n-1) V[i]=i;
int k=2;
while(sz(V)>=k)
{
FOR(i,k+1,sz(V))
{
if(calc(sz(V),k)<=calc(sz(V),i)) continue;
ll t=0;
ll x=sz(V);
while(x>i)
{
t+=(ll)(x/i)*(ll)i*(i-1)/2;
x=x/i+x%i;
}
t+=(ll)x*(x-1)/2;
if(S>=t) k=i;
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: 15
Accepted
time: 626ms
memory: 21860kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 63
Acceptable Answer
time: 2288ms
memory: 86012kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1099316 3452432143640083151 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1099316
Final Tests
Test #1:
score: 15
Accepted
time: 625ms
memory: 23076kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 63
Acceptable Answer
time: 2260ms
memory: 85988kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1099316 3452432143640083151 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1099316