QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#527400 | #9156. 百万富翁 | TheRaptor | 100 ✓ | 2088ms | 89760kb | C++17 | 2.1kb | 2024-08-22 14:56:32 | 2024-08-22 14:56:32 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
int richest(int n, int t, int s){
vector<int> a,b,ret;
if(t==1){
assert(n==1000);
for(int i=0; i<n; i++){
for(int j=i+1; j<n; j++){
a.push_back(i);
b.push_back(j);
}
}
ret=ask(a,b);
int ans=0;
for(int i=0; i<(int)ret.size(); i++){
if(a[i]==ans) ans=ret[i];
}
return ans;
}
vector<int> alive,tmp;
for(int i=0; i<n; i++) alive.push_back(i);
int bucs[]={2,2, 2, 2, 3, 6, 18, 183},at=0;
while((int)alive.size()>1){
int m=alive.size();
int buc=bucs[at];
at++;
int left=m%buc;
int g1=(m+buc-1)/buc,g2=(left==0?0:(buc-1-left+1));
g1-=g2;
assert(g1>=0);
if(buc==3){
g1=4,g2=20828;
buc++;
}
if(buc==6){
g1=0; g2=3472;
buc++;
}
if(buc==18){
g1=178,g2=5;
buc++;
}
if(buc==183){
g1=0,g2=1;
buc++;
}
//cout << m << ' ' << buc << '\n';
//cout << buc << '\n';
//cout << (m+buc-1)/buc*buc*(buc-1)/2 << '\n';
a.clear(); b.clear();
int cur=0;
for(int i=0; i<g1; i++){
for(int j=0; j<buc; j++){
for(int k=j+1; k<buc; k++){
if(cur+j>=m||cur+k>=m) continue;
a.push_back(alive[cur+j]);
b.push_back(alive[cur+k]);
}
}
cur+=buc;
}
for(int i=0; i<g2; i++){
for(int j=0; j<buc-1; j++){
for(int k=j+1; k<buc-1; k++){
if(cur+j>=m||cur+k>=m) continue;
a.push_back(alive[cur+j]);
b.push_back(alive[cur+k]);
}
}
cur+=buc-1;
}
ret=ask(a,b);
int cnt=0;
cur=0;
for(int i=0; i<g1; i++){
int best=alive[cur];
for(int j=0; j<buc; j++){
for(int k=j+1; k<buc; k++){
if(cur+j>=m||cur+k>=m) continue;
if(a[cnt]==best) best=ret[cnt];
cnt++;
}
}
tmp.push_back(best);
cur+=buc;
}
for(int i=0; i<g2; i++){
int best=alive[cur];
for(int j=0; j<buc-1; j++){
for(int k=j+1; k<buc-1; k++){
if(cur+j>=m||cur+k>=m) continue;
if(a[cnt]==best) best=ret[cnt];
cnt++;
}
}
tmp.push_back(best);
cur+=buc-1;
}
swap(tmp,alive);
tmp.clear();
}
return alive[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 610ms
memory: 25404kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2088ms
memory: 89760kb
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: 25372kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2068ms
memory: 89560kb
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