QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602662 | #9156. 百万富翁 | Littlelu | 51.99999 | 2671ms | 84264kb | C++14 | 1.9kb | 2024-10-01 11:41:50 | 2024-10-01 11:41:52 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int solve0(){
vector<int> aska,askb,resp;
int cnt=0;
for(int i=0;i<1000;++i) for(int j=i+1;j<1000;++j){
aska.push_back(i),askb.push_back(j),++cnt;
}
resp=ask(aska,askb);
vector<int> to[1000],in(1000),out(1000),ans;
for(int i=0;i<cnt;++i){
if(resp[i]==aska[i]) to[askb[i]].push_back(aska[i]),in[aska[i]]++,out[askb[i]]++;
else to[aska[i]].push_back(askb[i]),in[askb[i]]++,out[aska[i]]++;
}
for(int i=0;i<1000;++i) if(out[i]==0) return i;
return -1;
}
int solve1(){
int n=1000000,h=n;
vector<int> asks(h);
for(int i=0;i<h;++i) asks[i]=i;
while(h!=1){
if(h>=300){
int x2=-1,cnt=0;
if(h%2==1) x2=asks[h-1];
vector<int> aska,askb,resp;
for(int i=0;i<h/2;++i)
aska.push_back(asks[i*2]),askb.push_back(asks[i*2+1]),++cnt;
resp=ask(aska,askb);
asks.clear();
if(x2!=-1) asks.push_back(x2);
for(int i=0;i<cnt;++i){
if(resp[i]==aska[i]) asks.push_back(aska[i]);
else asks.push_back(askb[i]);
}
h=asks.size();
}else{
vector<int> aska,askb,resp;
int cnt=0;
for(int i=0;i<h;++i) for(int j=i+1;j<h;++j){
aska.push_back(asks[i]),askb.push_back(asks[j]),++cnt;
}
// alex;
resp=ask(aska,askb);
map<int,int> out;
for(int i=0;i<cnt;++i){
if(resp[i]==aska[i]) out[askb[i]]++;
else out[aska[i]]++;
}
int ans=-1;
for(int i=0;i<h;++i) if(out[asks[i]]==0) ans=asks[i];
return ans;
}
}
return asks[0];
}
int richest(int n,int t,int s){
if(n==1000) return solve0();
else return solve1();
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 663ms
memory: 23156kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 37
Acceptable Answer
time: 2609ms
memory: 84264kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645 14233204743512706019 0.435294 13281437197936769557
result:
points 0.435294 Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645
Final Tests
Test #1:
score: 15
Accepted
time: 647ms
memory: 24924kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 37
Acceptable Answer
time: 2671ms
memory: 84192kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645 14233204743512706019 0.435294 13281437197936769557
result:
points 0.435294 Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645