QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#492644 | #9156. 百万富翁 | leihonglongyin | 15 | 744ms | 87892kb | C++14 | 1.4kb | 2024-07-26 14:52:58 | 2024-07-26 14:52:58 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
using namespace std;mt19937 R(time(0));
vector<int>now,a,b,tmp,to;map<int,int>cnt;int tot,Tot;
void sol0(){cnt.clear(),a.clear(),b.clear();int len=now.size();
for(int i=0;i<len;i++)for(int j=i+1;j<len;j++)
a.push_back(now[i]),b.push_back(now[j]);
tmp=ask(a,b),now.resize(1);for(auto i:tmp)cnt[i]++;
for(auto i:cnt)if(i.second==len-1)return now[0]=i.first,void();
}
void sol1(int len,int x){
while(tot<x){a.clear(),b.clear(),tmp.clear(),to.clear();
shuffle(now.begin(),now.end(),R),tot++;vector<int>id;
for(int i=0;i<now.size()/len;i++)id.push_back(len);
int sy=now.size()%len;
if(sy){id.push_back(len);for(int i=1;i<=sy;i++)id[id.size()-i]--;}
for(int l=0,r,i=0;i<id.size();l=r+1,i++){r=l+id[i]-1;
for(int x=l;x<=r;x++)for(int y=x+1;y<=r;y++)
a.push_back(now[x]),b.push_back(now[y]);
}Tot+=a.size(),tmp=ask(a,b);int num=0;
for(int l=0,r,i=0;i<id.size();l=r+1,i++){cnt.clear(),r=l+id[i]-1;
for(int x=l;x<=r;x++)for(int y=x+1;y<=r;y++)
cnt[tmp[num++]]++;
for(int j=l;j<=r;j++)if(cnt[now[j]]==r-l)to.push_back(now[j]);
}now=to;
}
}
int richest(int N,int T,int S){now.clear(),Tot=tot=0;
if(T==1){for(int i=0;i<N;i++)now.push_back(i);return sol0(),now[0];}
for(int i=0;i<N;i++)now.push_back(i);
sol1(2,4),sol1(3,5),sol1(6,6),sol1(19,7);
return sol0(),now[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 742ms
memory: 24292kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Wrong Answer
time: 354ms
memory: 87700kb
input:
1000000 20 2000000 29091473
output:
Wrong answer 4459638610240858557 0.000000 6906350380861515327
result:
points 0.0 Wrong answer
Final Tests
Test #1:
score: 15
Accepted
time: 744ms
memory: 22480kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Wrong Answer
time: 353ms
memory: 87892kb
input:
1000000 20 2000000 29091471
output:
Wrong answer 4459638610240858557 0.000000 6906350380861515327
result:
points 0.0 Wrong answer