QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493009 | #9156. 百万富翁 | tuxuanming2024 | 100 ✓ | 3089ms | 88288kb | C++14 | 1.5kb | 2024-07-26 18:30:42 | 2024-07-26 18:30:42 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mx[1005][1005];
ll get(int x,int y) {return x*1000001ll+y;}
void work(vector<int>&p,int m)
{
int sz=p.size(),t=sz/m,r=sz%m;
vector<int>a,b;
unordered_map<ll,int>mx;
int B=t+1;
for(int i=0;i<B*r;i+=B)
for(int j=i;j<i+B;j++)
for(int k=j+1;k<i+B;k++) a.push_back(p[j]),b.push_back(p[k]);
B=t;
for(int i=(B+1)*r;i<sz;i+=B)
for(int j=i;j<i+B;j++)
for(int k=j+1;k<i+B;k++) a.push_back(p[j]),b.push_back(p[k]);
vector<int>c=ask(a,b),q;
for(int i=0;i<(int)a.size();i++) mx[get(a[i],b[i])]=c[i];
B=t+1;
for(int i=0;i<B*r;i+=B)
{
int res=p[i];
for(int j=i+1;j<i+B;j++)
if(mx[get(res,p[j])]==p[j]) res=p[j];
q.push_back(res);
}
B=t;
for(int i=(B+1)*r;i<sz;i+=B)
{
int res=p[i];
for(int j=i+1;j<i+B;j++)
if(mx[get(res,p[j])]==p[j]) res=p[j];
q.push_back(res);
}
p=q;
}
int richest(int n, int T, int S)
{
if(T==1)
{
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 i=0,k=0;i<n;i++)
for(int j=i+1;j<n;j++) mx[i][j]=c[k++];
int ans=0;
for(int i=1;i<n;i++) if(mx[ans][i]==i) ans=i;
return ans;
}
vector<int>p;
for(int i=0;i<n;i++) p.push_back(i);
vector<int>t={500000,250000,125000,62500,20832,3472,183,1};
for(auto x:t) work(p,x);
return p[0];
}
/*
g++ grader.cpp richest.cpp -o richest -O2 -std=c++14 -static && ./richest
*/
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 624ms
memory: 29444kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3089ms
memory: 86752kb
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: 618ms
memory: 29812kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3050ms
memory: 88288kb
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