QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#500574 | #9156. 百万富翁 | mirkdang | 15 | 769ms | 51144kb | C++14 | 1.3kb | 2024-08-01 15:19:00 | 2024-08-01 15:19:01 |
Judging History
answer
#include<bits/stdc++.h>
#include"richest.h"
using namespace std;
int x[8]={500000,250000,125000,62496,20832,3472,183,1};
int xhs(vector<int> x)
{
int l=x.size();
vector<int> a,b,c;map<int,int> mp;
a.reserve(l*(l-1)/2),b.reserve(l*(l-1)/2);
for(int i=0;i<l;i++)for(int j=i+1;j<l;j++)
a.emplace_back(x[i]),b.emplace_back(x[j]);
c=ask(a,b);for(int i:c)mp[i]++;
for(auto [p,q]:mp)if(q==l-1)return p;
}
int richest(int N,int T,int S)
{
if(N==1000)
{
vector<int> a;a.resize(N);
iota(a.begin(),a.end(),0);
return xhs(a);
}
if(N==1000000)
{
vector<int> a;a.resize(N);
iota(a.begin(),a.end(),0);
int n=N;
for(int r=0;r<8;r++)
{
vector<int> b(n/x[r]),c(n/x[r]+1),t;
t.reserve(x[r]);
for(int i=0;i<x[r]-n%x[r];i++)
{
for(int j=0;j<n/x[r];j++)
b[j]=a[n/x[r]*i+j];
t.emplace_back(xhs(b));
}
for(int i=0;i<n%x[r];i++)
{
for(int j=0;j<n/x[r]+1;j++)
c[j]=a[(x[r]-n%x[r])*(n/x[r])+(n/x[r]+1)*i+j];
t.emplace_back(xhs(c));
}
a=t,n=x[r];
}
return a[0];
}
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 769ms
memory: 20560kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Wrong Answer
time: 195ms
memory: 51068kb
input:
1000000 20 2000000 29091473
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries
Final Tests
Test #1:
score: 15
Accepted
time: 767ms
memory: 20528kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Wrong Answer
time: 151ms
memory: 51144kb
input:
1000000 20 2000000 29091471
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries