QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#489561 | #9156. 百万富翁 | xlwang | 100 ✓ | 2438ms | 94564kb | C++14 | 2.2kb | 2024-07-24 21:23:14 | 2024-07-24 21:23:15 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
#define fr(i,j,k) for(int i=j;i<=k;++i)
#define rf(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
vector<int> ans;
vector<int> answer,ans1,ans2;
const int Maxn=1e6+10;
int num[Maxn],tp[Maxn];
int n;
inline void check(int siz1,int siz2,int s1,int s2){
vector<int> ().swap(answer);
vector<int> ().swap(ans1);
vector<int> ().swap(ans2);
for(auto x:ans) num[x]=0;
fr(I,1,s1){
vector<int> now;vector<int> ().swap(now);
fr(i,1,siz1) now.pb(ans.back()),tp[ans.back()]=1,ans.pop_back();
for(int i=0;i<now.size();++i)
for(int j=i+1;j<now.size();++j)
ans1.pb(now[i]),ans2.pb(now[j]);
}
// cerr<<ans.size()<<endl;
fr(I,1,s2){
vector<int> now;vector<int> ().swap(now);
fr(i,1,siz2) now.pb(ans.back()),tp[ans.back()]=2,ans.pop_back();
for(int i=0;i<now.size();++i)
for(int j=i+1;j<now.size();++j)
ans1.pb(now[i]),ans2.pb(now[j]);
}
vector<int> Ans=ask(ans1,ans2);
// cerr<<"siz:"<<Ans.size()<<endl;
for(auto x:Ans) num[x]++;
fr(i,0,n-1) if(num[i]){
if(tp[i]==1 && num[i]==siz1-1) answer.pb(i);
if(tp[i]==2 && num[i]==siz2-1) answer.pb(i);
}
swap(ans,answer);
}
int richest(int N, int T, int S) {
n=N;fr(i,0,n-1) ans.pb(i);
if(n==1000){
vector<int> ans1,ans2;
vector<int> ().swap(ans1);vector<int> ().swap(ans2);
fr(i,0,n-1) fr(j,i+1,n-1) ans1.pb(i),ans2.pb(j);
fr(i,0,n-1) num[i]=0;
vector<int> Ans=ask(ans1,ans2);
// cerr<<Ans.size()<<endl;
for(auto x:Ans) num[x]++;
fr(i,0,n-1) if(num[i]==n-1) return i;
}
check(2,0,500000,0);
// cerr<<ans.size()<<endl;
check(2,0,250000,0);
// cerr<<ans.size()<<endl;
check(2,0,125000,0);
// cerr<<ans.size()<<endl;
check(2,0,62500,0);
// cerr<<ans.size()<<endl;
check(3,4,20832,1);
// cerr<<ans.size()<<endl;
check(6,7,3471,1);
// cerr<<ans.size()<<endl;
check(19,18,178,5);
// cerr<<ans.size()<<endl;
check(183,0,1,0);
// cerr<<ans.size()<<endl;
return ans.back();
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 604ms
memory: 29364kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2434ms
memory: 94448kb
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: 620ms
memory: 27436kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2438ms
memory: 94564kb
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