QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#498665 | #9156. 百万富翁 | sunrise2048 | 100 ✓ | 2063ms | 93732kb | C++14 | 1.6kb | 2024-07-30 17:24:14 | 2024-07-30 17:24:14 |
Judging History
answer
#include<bits/stdc++.h>
#include "richest.h"
using namespace std;
using ll=long long;
const int f[]={500000,250000,125000,62500,20833,3472,183,1};
const int N=1e6+5;
vector<int> v;
int cn[N];
void ak(int z){
int n=v.size();
if(n<=z)return;
int len1=n%z;
int len0=z-n%z;
vector<int> s,t;
for(int k=0;k<len1;++k){
int l=k*(n/z+1);
int r=(k+1)*(n/z+1)-1;
for(int i=l;i<=r;++i){
for(int j=i+1;j<=r;++j){
s.push_back(v[i]);
t.push_back(v[j]);
}
}
}
for(int k=0;k<len0;++k){
int l=len1*(n/z+1)+k*(n/z);
int r=l+n/z-1;
for(int i=l;i<=r;++i){
for(int j=i+1;j<=r;++j){
s.push_back(v[i]);
t.push_back(v[j]);
}
}
}
vector<int> as=ask(s,t);
for(int i:as)cn[i]++;
as.clear();
for(int k=0;k<len1;++k){
int l=k*(n/z+1);
int r=(k+1)*(n/z+1)-1;
for(int i=l;i<=r;++i){
if(cn[v[i]]==n/z){
as.push_back(v[i]);
}
cn[v[i]]=0;
}
}
for(int k=0;k<len0;++k){
int l=len1*(n/z+1)+k*(n/z);
int r=l+n/z-1;
for(int i=l;i<=r;++i){
if(cn[v[i]]==n/z-1){
as.push_back(v[i]);
}
cn[v[i]]=0;
}
}
v=as;
}
int richest(int n,int t,int s){
v.clear();
for(int i=0;i<n;++i)v.push_back(i);
if(t==1){
ak(1);
return v[0];
}
int cn=0;
while(v.size()!=1){
ak(f[cn]);++cn;
}
return v[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 620ms
memory: 27500kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2035ms
memory: 93732kb
input:
1000000 20 2000000 29091473
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
Final Tests
Test #1:
score: 15
Accepted
time: 616ms
memory: 25504kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2063ms
memory: 93684kb
input:
1000000 20 2000000 29091471
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944