QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492240 | #9156. 百万富翁 | zwh2008# | 15 | 617ms | 23076kb | C++14 | 1.1kb | 2024-07-26 10:45:08 | 2024-07-26 10:45:08 |
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 richest(int n,int T,int S) {
if(T==1) {
vector<int>a,b,ct(n);
for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)a.push_back(i),b.push_back(j);
vector<int>c=ask(a,b);
for(int i:c)ct[i]++;
for(int i=0;i<n;i++)if(ct[i]==n-1)return i;
}
vector<int>a(n),del(n);
iota(a.begin(),a.end(),0);
while(a.size()>1) {
shuffle(a.begin(),a.end(),rd);
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<min(m/10,1);i++) {
// int x,y;
// do x=rg(0,n-1),y=rg(0,n-1);while(x==y||(x+1)%m==y||(y+1)%m==x);
// qa.push_back(x),qb.push_back(y);
// }
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;
}
return a[0];
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 613ms
memory: 21800kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 617ms
memory: 23076kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output