QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492613 | #9156. 百万富翁 | Augenstern | 77.99996 | 2812ms | 358472kb | C++14 | 2.7kb | 2024-07-26 14:30:12 | 2024-07-26 14:30:12 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
//#define int long long
//#define ull unsigned int
//#define lll __int128
//#define double long double
using namespace std;
const long long INF=1e9+5;
//const long long mod=998244353,orm=3;
const long long mod=1000000007;
const int MAXN=2000005;
const double eps=1e-6;
vector<pair<int,int> > v2[MAXN],v[MAXN];
vector<int> A,B,ans,v3[MAXN];
int n,rt=0,tot=0;
int B1[10]={183,18,6,3,2,2,2,2};
int d[MAXN],be[MAXN],vis[MAXN];
vector<int> son[MAXN];
void calc(int dep,int &k,int l,int r) {
k=++tot,d[k]=dep;
int len=r-l+1;
// if(dep<=5) cout<<dep<<" "<<l<<" "<<r<<" "<<len<<"\n";
if(len==1) {
be[k]=l;
return ;
}
if(len<=B1[dep]||dep==8) {
// cout<<B1[dep]<<" "<<dep<<"\n";
for(int i=l;i<=r;i++) {
for(int j=i+1;j<=r;j++) v[k].push_back({i,j});
}
return ;
}
int sz=len/B1[dep];
for(int i=1;i<B1[dep];i++) {
son[k].push_back(0);
calc(dep+1,son[k][son[k].size()-1],l,l+sz-1);l+=sz;
}
if(l<=r) son[k].push_back(0),calc(dep+1,son[k][son[k].size()-1],l,r);
for(int i=0;i<son[k].size();i++) {
for(int j=i+1;j<son[k].size();j++) {
v2[k].push_back({son[k][i],son[k][j]});
}
}
}
void clear() {
A.clear(),B.clear(),ans.clear();
}
void Clear() {
for(int i=0;i<=max({tot,n,100});i++) {
d[i]=be[i]=vis[i]=0;
v[i].clear(),v2[i].clear(),v3[i].clear(),son[i].clear();
}
clear();
tot=0;rt=0;
}
int O=0,O2=0;
int richest(int N, int T, int S) {
n=N;
if(n<=1000) B1[0]=1000;
calc(0,rt,1,n);
for(int i=1;i<=tot;i++) {
for(auto p:v[i]) {
A.push_back(p.first-1),B.push_back(p.second-1);
}
}
ans=ask(A,B);int nw=0;
for(int i=1;i<=tot;i++) {
int id=0;
for(auto p:v[i]) {
if(ans[nw++]==p.first-1) vis[p.second]=1;
else vis[p.first]=1;
}
for(auto p:v[i]) {
if(!vis[p.first]) id=p.first;
if(!vis[p.second]) id=p.second;
}
if(v[i].size()) be[i]=id;
}
clear();nw=0;
int mx=0;
for(int i=1;i<=tot;i++) v3[d[i]].push_back(i),mx=max(mx,d[i]);
for(int i=mx;i>=0;i--) {
for(int j:v3[i]) {
for(auto p:v2[j]) {
if(!be[p.first]||!be[p.second]) {
cout<<be[p.first]<<" "<<be[p.second]<<"\n";
cout<<v[p.first].size()<<" "<<v[p.second].size()<<"\n";
assert(0);
}
A.push_back(be[p.first]-1),B.push_back(be[p.second]-1);
}
}
if(A.size()) ans=ask(A,B);nw=0;
for(int j:v3[i]) {
for(auto p:v2[j]) {
if(ans[nw++]==be[p.first]-1) vis[be[p.second]]=1;
else vis[be[p.first]]=1;
}
int id=0;
for(auto p:v2[j]) {
if(!vis[be[p.first]]) id=be[p.first];
if(!vis[be[p.second]]) id=be[p.second];
}
if(v2[j].size()) be[j]=id;
}
clear();nw=0;
}
int res=be[rt];Clear();
return res-1;
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 694ms
memory: 221420kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 63
Acceptable Answer
time: 2784ms
memory: 345048kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1094062 680228207135401537 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1094062
Final Tests
Test #1:
score: 15
Accepted
time: 670ms
memory: 221960kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 63
Acceptable Answer
time: 2812ms
memory: 358472kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1094062 680228207135401537 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1094062