QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492388 | #9156. 百万富翁 | Augenstern# | 0 | 69ms | 238244kb | C++14 | 2.8kb | 2024-07-26 11:50:05 | 2024-07-26 11:50:16 |
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=1000005;
const double eps=1e-6;
vector<pair<int,int> > v2[MAXN],v[MAXN];
vector<int> A,B,ans,v3[MAXN];
int N,B1=2,B2=1000,B3=10,rt=0,tot=0;
int d[MAXN],be[MAXN],vis[MAXN];
int son[MAXN][22];
void calc(int dep,int &k,int l,int r) {
if(!k) k=++tot,d[k]=dep;
int len=r-l+1;
if(len==1) {
be[k]=l;
return ;
}
if(len<=B1) {
for(int i=l;i<=r;i++) {
for(int j=i+1;j<=r;j++) v[k].push_back({i,j});
}
return ;
}
if(len>=B2) {
int sz=len/B3;
for(int i=1;i<B3;i++) {
calc(dep+1,son[k][++son[k][0]],l,l+sz-1);l+=sz;
}
if(l<=r) calc(dep+1,son[k][++son[k][0]],l,r);
for(int i=1;i<=son[k][0];i++) {
for(int j=i+1;j<=son[k][0];j++) {
v2[k].push_back({son[k][i],son[k][j]});
}
}
return ;
}
int sz=len/B1;
for(int i=1;i<B1;i++) {
calc(dep+1,son[k][++son[k][0]],l,l+sz-1);l+=sz;
}
if(l<=r) calc(dep+1,son[k][++son[k][0]],l,r);
for(int i=1;i<=son[k][0];i++) {
for(int j=i+1;j<=son[k][0];j++) {
v2[k].push_back({son[k][i],son[k][j]});
}
}
}
void clear() {
A.clear(),B.clear(),ans.clear();
}
void Clear() {
rt=0;
for(int i=1;i<=tot;i++) {
son[i][0]=d[i]=be[i]=vis[i]=0;
v[i].clear(),v2[i].clear(),v3[i].clear();
}
tot=0;
}
//vector<int> ask(vector<int> x,vector<int> y) {
// vector<int> res;
// for(int i=0;i<x.size();i++) {
// res.push_back(max(x[i],y[i]));
// }
// return res;
//}
int richest(int N, int T, int S) {
if(N<=1000) B1=1000;
calc(0,rt,1,N);
for(int i=1;i<=tot;i++) {
for(auto p:v[i]) {
A.push_back(p.first),B.push_back(p.second);
}
}
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) 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]) assert(0);
A.push_back(be[p.first]),B.push_back(be[p.second]);
}
}
ans=ask(A,B);nw=0;
for(int j:v3[i]) {
for(auto p:v2[j]) {
if(ans[nw++]==be[p.first]) 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;
}
詳細信息
Pretests
Pretest #1:
score: 0
Wrong Answer
time: 8ms
memory: 94308kb
input:
1000 1 499500 957319859
output:
Index out of bounds 9775460264716263939 0.000000 6906350380861515327
result:
points 0.0 Index out of bounds
Pretest #2:
score: 0
Wrong Answer
time: 69ms
memory: 238092kb
input:
1000000 20 2000000 29091473
output:
Index out of bounds 9775460264716263939 0.000000 6906350380861515327
result:
points 0.0 Index out of bounds
Final Tests
Test #1:
score: 0
Wrong Answer
time: 15ms
memory: 94420kb
input:
1000 1 499500 957319857
output:
Index out of bounds 9775460264716263939 0.000000 6906350380861515327
result:
points 0.0 Index out of bounds
Test #2:
score: 0
Wrong Answer
time: 67ms
memory: 238244kb
input:
1000000 20 2000000 29091471
output:
Index out of bounds 9775460264716263939 0.000000 6906350380861515327
result:
points 0.0 Index out of bounds