QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#492728 | #9156. 百万富翁 | Augenstern | 100 ✓ | 2541ms | 161904kb | C++14 | 1.7kb | 2024-07-26 15:33:38 | 2024-07-26 15:33:38 |
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<int> A,B,ans,now,v[MAXN];
int n;
int B1[10]={1000000,500000,250000,125000,62497,20832,3472,183,1};
int vis[MAXN];
void clear() {
A.clear(),B.clear(),ans.clear();
}
void calc() {
for(int i=1;i<=n;i++) now.push_back(i);
for(int i=1;i<=8;i++) {
int k=B1[i];
for(int j=0;j<now.size();j++) v[j%k].push_back(now[j]);
for(int j=0;j<k;j++) {
for(int p=0;p<v[j].size();p++) {
for(int q=p+1;q<v[j].size();q++) {
A.push_back(v[j][p]-1),B.push_back(v[j][q]-1);
}
}
}
ans=ask(A,B);int nw=0;
now.clear();
for(int j=0;j<k;j++) {
for(int p=0;p<v[j].size();p++) {
for(int q=p+1;q<v[j].size();q++) {
if(ans[nw++]==v[j][p]-1) vis[v[j][q]]=1;
else vis[v[j][p]]=1;
}
}
for(int p:v[j]) if(!vis[p]) now.push_back(p);v[j].clear();
}
clear();
}
}
void Clear() {
for(int i=0;i<=1000000;i++) {
vis[i]=0;
v[i].clear();
}
clear();now.clear();
}
int O=0,O2=0;
int richest(int N, int T, int S) {
n=N;
if(n<=1000) {
for(int i=1;i<=n;i++) {
for(int j=i+1;j<=n;j++) {
A.push_back(i-1),B.push_back(j-1);
}
}
ans=ask(A,B);
int nw=0;
for(int i=1;i<=n;i++) {
for(int j=i+1;j<=n;j++) {
if(ans[nw++]==i-1) vis[j]=1;
else vis[i]=1;
}
}clear();int id=0;
for(int i=1;i<=n;i++) if(!vis[i]) id=i;
Clear();return id-1;
}
calc();
int res=now[0];Clear();
return res-1;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 641ms
memory: 78732kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2541ms
memory: 161904kb
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: 646ms
memory: 76472kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2464ms
memory: 161900kb
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