QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#492440 | #9156. 百万富翁 | fqoi | 100 ✓ | 2164ms | 107436kb | C++14 | 1.1kb | 2024-07-26 12:22:52 | 2024-07-26 12:22:56 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
const int M=10,NN=1e6+114;
int cnt[NN],ans[M][NN],Q[M]={1000000,500000,250000,125000,62496,20832,3472,183,1};
int richest(int n,int T,int S){
if(n==1000){
memset(cnt,0,sizeof(int[1000]));
vector<int> a,b;
for(int i=0;i<n;++i){
for(int j=i+1;j<n;++j){
a.push_back(i);
b.push_back(j);
}
}
vector<int> c=ask(a,b);
for(int k:c) ++cnt[k];
return max_element(cnt,cnt+n)-cnt;
}
for(int i=0;i<n;++i) ans[0][i]=i;
for(int i=1;i<=8;++i){
vector<int> a,b;
for(int j=0,k=0;j<Q[i];++j){
int K=Q[i-1]/Q[i]+(j<Q[i-1]%Q[i]);
for(int o1=k;o1<k+K;++o1){
for(int o2=o1+1;o2<k+K;++o2){
a.push_back(ans[i-1][o1]);
b.push_back(ans[i-1][o2]);
}
}
k+=K;
}
vector<int> c=ask(a,b);
memset(cnt,0,sizeof(cnt));
for(int k:c) ++cnt[k];
for(int j=0,k=0;j<Q[i];++j){
int K=Q[i-1]/Q[i]+(j<Q[i-1]%Q[i]);
ans[i][j]=*max_element(ans[i-1]+k,ans[i-1]+k+K,[](int x,int y)->bool{return cnt[x]<cnt[y];});
k+=K;
}
}
return ans[8][0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 623ms
memory: 27420kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2151ms
memory: 105300kb
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: 619ms
memory: 27420kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2164ms
memory: 107436kb
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