QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#498139 | #9156. 百万富翁 | ljga_ | 100 ✓ | 1961ms | 99648kb | C++14 | 1.8kb | 2024-07-30 00:17:15 | 2024-07-30 00:17:15 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
typedef long long ll;
/*
500000*2
250000*2
125000*2
62500*2
20832*3 1*4
3471*6 1*7
168*19 14*20
1*182
*/
// 1099947
int cnt[1000010];
vector <int> a,b,c,d,e;
pair<pair<int,int>,pair<int,int> > t[10]={
{{0,0},{0,0}},
{{1,183},{0,0}},
{{5,18},{178,19}},
{{3471,6},{1,7}},
{{20832,3},{1,4}},
{{62500,2},{0,0}},
{{125000,2},{0,0}},
{{250000,2},{0,0}},
{{500000,2},{0,0}}
};
int richest(int n,int T,int S){
if(n==1000){
for(int i=0;i<n;i++)
cnt[i]=0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
a.push_back(i),b.push_back(j);
c=ask(a,b);
a.clear();b.clear();
for(int x:c)
cnt[x]++;
for(int i=0;i<n;i++)
if(cnt[i]==n-1)
return i;
}
d.resize(n);
for(int i=0;i<n;i++)
d[i]=i;
for(int i=8;i>0;i--){
int xc=t[i].first.first,x=t[i].first.second;
int x1c=t[i].second.first,x1=t[i].second.second;
int p=0;
for(int j=0;j<xc;j++){
for(int k=p;k<p+x;k++)
for(int l=k+1;l<p+x;l++)
a.push_back(d[k]),b.push_back(d[l]);
p+=x;
}
for(int j=0;j<x1c;j++){
for(int k=p;k<p+x1;k++)
for(int l=k+1;l<p+x1;l++)
a.push_back(d[k]),b.push_back(d[l]);
p+=x1;
}
c=ask(a,b);
e.clear();
p=0;
int pc=0;
for(int j=0;j<xc;j++){
for(int i=pc;i<pc+x*(x-1)/2;i++)
cnt[c[i]]++;
for(int i=p;i<p+x;i++)
if(cnt[d[i]]==x-1)
e.push_back(d[i]);
for(int i=p;i<p+x;i++)
cnt[d[i]]=0;
p+=x;
pc+=x*(x-1)/2;
}
for(int j=0;j<x1c;j++){
for(int i=pc;i<pc+x1*(x1-1)/2;i++)
cnt[c[i]]++;
for(int i=p;i<p+x1;i++)
if(cnt[d[i]]==x1-1)
e.push_back(d[i]);
for(int i=p;i<p+x1;i++)
cnt[d[i]]=0;
p+=x1;
pc+=x1*(x1-1)/2;
}
d=e;
a.clear();b.clear();
}
return e[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 607ms
memory: 26172kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 1961ms
memory: 99648kb
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: 608ms
memory: 24576kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 1956ms
memory: 99620kb
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