QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603037#9156. 百万富翁Littlelu51.99999 2311ms84168kbC++141.9kb2024-10-01 14:20:142024-10-01 14:20:15

Judging History

你现在查看的是最新测评结果

  • [2024-10-01 14:20:15]
  • 评测
  • 测评结果:51.99999
  • 用时:2311ms
  • 内存:84168kb
  • [2024-10-01 14:20:14]
  • 提交

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>245){
            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: 642ms
memory: 23168kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 37
Acceptable Answer
time: 2311ms
memory: 84168kb

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: 24864kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 37
Acceptable Answer
time: 2268ms
memory: 84132kb

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