QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492351 | #9156. 百万富翁 | zwh2008# | 68.99999 | 2250ms | 105600kb | C++14 | 1.7kb | 2024-07-26 11:35:12 | 2024-07-26 11:35:15 |
Judging History
answer
#include<bits/stdc++.h>
#include "richest.h"
using namespace std;
mt19937 rd(5384);
int rg(int l,int r){return rd()%(r-l+1)+l;}
int slv(int n,vector<int>d) {
int m=d.size();
vector<int>a,b,ct(n);
for(int i=0;i<m;i++)for(int j=i+1;j<m;j++)a.push_back(d[i]),b.push_back(d[j]);
vector<int>c=ask(a,b);
for(int i:c)ct[i]++;
for(int i=0;i<n;i++)if(ct[i]==m-1)return i;
}
int richest(int n,int T,int S) {
vector<int>a(n),del(n);
iota(a.begin(),a.end(),0);
if(T==1)return slv(n,a);
while(a.size()>100000) {
vector<int>qa,qb,qc,na,del(a.size());
for(int i=0;i+1<a.size();i+=2)qa.push_back(a[i]),qb.push_back(a[i+1]);
qc=ask(qa,qb);
for(int i=0;i<qc.size();i++)if(qc[i]==qa[i])del[i*2+1]=1;else del[i*2]=1;
for(int i=0;i<a.size();i++)if(!del[i])na.push_back(a[i]);
a=na;
}
while(a.size()>10000) {
int m=a.size();
vector<int>qa,qb,qc,na;
for(int i=0;i<m;i++)qa.push_back(a[i]),qb.push_back(a[(i+1)%m]);
qc=ask(qa,qb);
for(int i=0;i<qc.size();i++)if(qc[i]==qa[i])del[qb[i]]=1;else del[qa[i]]=1;
for(int i:a)if(!del[i])na.push_back(i);else del[i]=0;
a=na;
}
while(a.size()>400) {
int m=a.size();
vector<int>qa,qb,qc,na;
for(int i=0;i<m;i++)qa.push_back(a[i]),qb.push_back(a[(i+1)%m]);
for(int i=0;i<m;i+=2)qa.push_back(a[i]),qb.push_back(a[(i+2)%m]);
qc=ask(qa,qb);
for(int i=0;i<qc.size();i++)if(qc[i]==qa[i])del[qb[i]]=1;else del[qa[i]]=1;
for(int i:a)if(!del[i])na.push_back(i);else del[i]=0;
a=na;
}
cerr<<a.size()<<'\n';
// return a[0];
return slv(n,a);
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 622ms
memory: 23256kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 54
Acceptable Answer
time: 2200ms
memory: 101572kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1060666 11698536928095661223 0.635294 4439523384460221017
result:
points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1060666
Final Tests
Test #1:
score: 15
Accepted
time: 631ms
memory: 25184kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 54
Acceptable Answer
time: 2250ms
memory: 105600kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1061493 8967617939531833893 0.635294 4439523384460221017
result:
points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1061493