QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876376 | #9156. 百万富翁 | Juefan | 100 ✓ | 2381ms | 102188kb | C++14 | 1.5kb | 2025-01-30 20:23:13 | 2025-01-30 20:23:13 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) begin(x),end(x)
#define ran(x,l,r) begin(x)+l,begin(x)+(r+1)
#define F(i,a,b) for(int i=a,i##E=b;i<=i##E;i++)
#define UF(i,a,b) for(int i=a,i##E=b;i>=i##E;i--)
#define sz(x) int(x.size())
#define vec vector
template<typename T>
void operator+=(vec<T> &a,const T&b) {a.push_back(b);}
int R[]{500000,250000,125000,62500,20833,3472,183,1};
// std::vector <int> ask(std::vector <int> a, std::vector <int> b) {
// return a;
// }
int richest(int N,int T,int S) {
int n=N;
if(N==1000) {
vec<int> a,b;
F(i,0,n-1) F(j,i+1,n-1) {
a+=i,b+=j;
}
vec<int> c(n);
for(int x:ask(a,b)) c[x]++;
F(i,0,n-1) if(c[i]==n-1) return i;
return 1;
}
int now{N};
vec<int> A;
F(i,0,n-1) A+=i;
for(int r:R) {
vec<int> a,b;
auto push=[&](vec<int> t) {
for(int x:t) for(int y:t) if(x<y) a+=x,b+=y;
};
vec<int> V;
F(i,1,r) V+=now/r;
F(i,0,now%r-1) V[i]++;
vec<int> NOT(n,1);
for(int x:A) NOT[x]=0;
vec<int> B,tmp;
for(int x:A) {
tmp+=x;
if(sz(tmp)==V.back()) push(tmp),tmp={},V.pop_back();
}
vec<int> c=ask(a,b);
F(i,0,sz(a)-1) NOT[a[i]^b[i]^c[i]]=1;
F(i,0,n-1) if(!NOT[i]) B+=i;
cerr<<r<<' '<<sz(B)<<endl;
assert(sz(B)==r);
swap(A,B);now=sz(A);
} return A[0];
}
// int main() {richest(1000000,20,2000000);}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 605ms
memory: 23604kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2381ms
memory: 86428kb
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: 606ms
memory: 25128kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2375ms
memory: 102188kb
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